Ir al contenido principal
Petanque Life

Self-service Data Import

F16.18 10 funcionalidades Planificado

En resumen

Self-service data-import wizard letting a federation or club load existing legacy data (players, licenses, clubs, memberships) from CSV or Excel through a six-step flow: auto-mapping with multilingual aliases, dry-run schema and domain validation, background-job commit in 500-row batches with progress, one-hour rollback window deleting every created document, configurable per-job dedup strategy and a full ImportJob audit trail.

Cómo funciona

The import pipeline starts with a parser that auto-detects CSV delimiters, handles BOM-prefixed UTF-8, accepts both .xlsx and legacy .xls, and converts Excel serial dates to ISO strings before they reach validation. Files up to documented size land on the API where they live as a temporary artefact tied to the in-progress ImportJob.

The admin UI at /import walks operators through six steps: pick the resource type (players, licenses, clubs or memberships), upload the file, review the auto-mapped column headers, run dry-run, commit, watch status. Auto-mapping is case-insensitive and ships with common aliases — email matches "e-post", first_name matches "förnamn" or "prenom" — so a federation that exports from a legacy system rarely needs to remap by hand. Anything ambiguous surfaces as a manual mapping step.

Dry-run is the safety check. It runs both schema validation (right types, required fields, format constraints) and domain validation (license number unique within tenant, club code exists, age within license-type bounds) without writing anything. Up to 100 errors come back inline with row number and column so the operator can fix the source spreadsheet before committing. When the operator hits commit, the pipeline schedules a background job that processes the file in 500-row batches; the job updates progress per batch so the operator sees a moving counter rather than wondering whether the system is alive.

Mistakes happen, so rollback is built in. Within 60 minutes of commit the operator can roll back the whole job; the service walks the created_doc_ids array and deletes every document the job created, leaving the database as if the import never happened. After the window the rollback endpoint returns 410 Gone — beyond an hour the data is considered live and rollback would risk cascading damage to records other users have started touching.

Dedup strategy is configurable per job: skip (ignore collisions), update (overwrite the existing record from the import row) or fail (abort the whole job on the first collision). Per-resource importers (players, licenses, clubs, memberships) define their own field schemas and dedup keys — license number for licenses, email for players. Templates are downloadable through GET /import/templates/{resource} as a CSV with the right column headers and an example row, and every job persists as an ImportJob with status, mapping, validation errors, created_doc_ids and timestamps so an audit can reconstruct exactly what happened.

Capacidades clave

  • CSV and Excel parsing with delimiter auto-detect, BOM support and Excel-date conversion
  • Six-step admin wizard: type → upload → mapping → dry-run → commit → status
  • Auto-mapping of column headers with multilingual aliases (email/e-post, förnamn, prenom)
  • Dry-run schema and domain validation with up to 100 inline errors before any write
  • Background-job commit in 500-row batches with per-batch progress updates
  • One-hour rollback window deleting all created documents from a job
  • Configurable per-job dedup strategy (skip, update, fail)
  • Per-resource importers for players, licenses, clubs and memberships with schema-specific dedup keys
  • Downloadable CSV templates per resource and full ImportJob audit trail

En la práctica

A national federation onboards onto the platform with 8 400 historical player records in a 14-year-old members system. The federation admin downloads the players template, exports their legacy data, opens /import and uploads the file. Auto-mapping nails 18 of 20 columns (e-post → email, postnummer → postal_code); they map the last two manually.

Dry-run reports 47 errors — duplicate license numbers, two players younger than the minimum age — they fix the spreadsheet, re-upload, dry-run clean. Commit launches: 17 batches over four minutes, progress 6 % → 100 %. Spot-check confirms the records look right.

Twenty minutes later they realise they imported with the wrong tenant context — they hit rollback, all 8 400 records vanish in seconds, they re-import under the correct tenant, done by lunch.

Funcionalidades de este subsistema

10
ID Status Funcionalidades
F16.18.01 Entregado CSV- och Excel-parsing med auto-detektering av delimiter, BOM-stöd och Excel-datumkonvertering. ✅ PL-T056
F16.18.02 Entregado 6-stegs import-wizard i admin (/import): välj typ → ladda upp → mappning → dry-run → commit → status. ✅ PL-T056
F16.18.03 Entregado Auto-mappning av kolumnrubriker (case-insensitiv + vanliga aliaser: email, e-post, förnamn, etc.). ✅ PL-T056
F16.18.04 Entregado Dry-run validering: schema-validering + domänvalidering utan att skriva data. Upp till 100 fel inline. ✅ PL-T056
F16.18.05 Entregado Commit i bakgrundsjobb med batch-storlek 500 rader. Progress-uppdatering per batch. ✅ PL-T056
F16.18.06 Entregado Rollback inom 1 timme: tar bort alla created_doc_ids från jobbet. 410 Gone efter fönstret. ✅ PL-T056
F16.18.07 Entregado Konfigurerbar dedup-strategi per jobb: skip, update, fail vid kollisioner. ✅ PL-T056
F16.18.08 Entregado Per-resurs importerare (players, licenses, clubs, memberships) med egna fältscheman och dedup-nycklar. ✅ PL-T056
F16.18.09 Entregado Template-generator: GET /import/templates/{resource} returnerar CSV med rätt kolumner och exempelrad. ✅ PL-T056
F16.18.10 Entregado ImportJob-modell med fullständig audit trail: status, mappning, valideringsfel, skapade doc-ID:n, tidsstämplar. ✅ PL-T056