Implementation Plan: Unify CSV Upload Ingestion¶
Goal¶
Unify CSV upload + API sync under one job-creation pipeline that stores file paths in job meta, dispatches providers via the factory, and exposes job status via SSE.
Non-Goals¶
- Redesigning the ingestion model schema.
- Implementing new providers beyond the equipment CSV provider.
Current State (Summary)¶
- Uploads go through
POST /files/tmpand returnFileNode.path. - Job creation happens in
POST /sync/data-entries/{module_type_id}withingestion_method. - SSE streams only status fields, not identifiers.
Target Flow¶
- Client uploads CSV to
files/tmp→ getsfile_path. - Client calls
POST /sync/data-entries/{module_type_id}with: ingestion_method=csvtarget_typeyearconfig.file_path=<uploaded path>- Backend creates
DataIngestionJob, enqueues ingestion. - Provider reads
file_pathfromconfig/meta. - Client subscribes to SSE to map updates to module/target rows.
Required Changes¶
Backend¶
- Extend
SyncRequestto acceptfile_path(or ensureconfig.file_pathis passed through). - Store
file_pathin jobmetaat creation. - Ensure CSV providers read
file_pathfromconfigormeta. - SSE payload must include identifiers:
job_id,module_type_id,target_type,year,status,status_message,updated_at.
Frontend¶
- Upload via
files/tmp, store returnedfile_path. - Call
initiateSync()withingestion_method=csvandconfig.file_path. - Add SSE listener in Pinia to update per module/target status.
example of /files response¶
[
{
"name": "seed_equipment_data.csv",
"path": "tmp/1770110939379406/seed_equipment_data.csv",
"size": 6683,
"mime_type": "text/csv",
"is_file": true,
"children": []
}
]
Where to find upload interface?¶
-
- modal and store for upload frontend
- frontend/src/components/organisms/data-management/FilesUploadDialog.vue
- frontend/src/stores/files.ts