Add CSV imports and granular competition data cleanup

This commit is contained in:
larssand
2026-08-27 17:56:50 +02:00
parent a87c64a47c
commit e5af42ce2d
9 changed files with 504 additions and 8 deletions

View File

@@ -438,6 +438,26 @@ Owns:
- OBS settings UI
- branding/audio settings UI
- import/export settings UI
- destructive data-clear controls and confirmation dialogs
`settings.js` never parses CSV or mutates canonical collections directly. It reads the selected file and calls the injected `importDirectoryCsv(text, type)` controller from `app.js`. Clear buttons similarly call the injected `clearDataScope(scope)` controller after confirmation.
### `src/csv_import.js`
Type:
- pure directory CSV parser and merge logic
Owns:
- RFC-style quoted field parsing for comma-, semicolon-, and tab-separated files
- UTF-8 BOM and Swedish/English column aliases
- driver matching by stable ID, transponder, or unique name + class
- car matching by stable ID, transponder, or unique name
- automatic class creation for imported class names
- non-destructive field merge where empty CSV cells do not erase existing values
- added/updated/skipped import counters
It does not access DOM, browser storage, or global state. `app.js` passes current collections and `uid`, then normalizes and persists the returned collections.
Clear operations remove canonical state and dependent references only. The separate SQLite `passings` table is intentionally retained as an audit log because the LAN UI has no authenticated administrator boundary. Do not add a destructive passings endpoint without first implementing real admin authentication and authorization.
### `src/training_logic.js`
Type:
@@ -557,6 +577,7 @@ Owns:
- `src/judging_logic.js`
- `src/training_logic.js`
- `src/training_views.js`
- `src/csv_import.js`
### Training/profile imports
- `src/core_views.js` imports `src/driver_profile_logic.js`
@@ -1080,6 +1101,7 @@ sequenceDiagram
| `src/core_views.js` | view/render | none | `app.js` | yes | no | no |
| `src/misc_views.js` | view/render | none | `app.js` | yes | no | no |
| `src/settings.js` | view/render | none | `app.js` | yes | no | no |
| `src/csv_import.js` | pure import logic | none | `app.js`, tests | no | no | no, returns merged collections |
| `src/training_logic.js` | logic | none | `app.js` | no | no | no, returns normalized/derived data |
| `src/training_views.js` | view/controller | none | `app.js` | yes | no | yes, through injected state access |
| `public-training.html` | standalone entry | `public_training.css`, `public_training.js` | `server.js` route | root only | no | no |