tracksolid_timescale_grafan.../tools
david kiania 458e0be101 feat(tools): import_drivers_csv reads raw Tracksolid Pro export format
Add auto-detecting header-alias layer (_EXPORT_HEADER_ALIASES) so
import_drivers_csv ingests the raw Tracksolid Pro device export
(Title-Case headers: IMEI, Driver Name, LicensePlateNo., Model,
Vehicle Model, …) in addition to the original snake_case schema-mirror
CSV. Add customer_name/device_group to the write set, extend the
driver-placeholder skip list (Unassigned/UG/UG Crane), and exclude
activation_time/expiration/device_group (date-only/casing churn that
would degrade precise API-set values).

Used to apply the 260625 telematics quality-check file: 152 devices
updated (device_name, driver_name, plate, vehicle type, depot_address).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 14:52:11 +03:00
..
__init__.py feat(tools): import_drivers_csv reads raw Tracksolid Pro export format 2026-06-25 14:52:11 +03:00
import_drivers_csv.py feat(tools): import_drivers_csv reads raw Tracksolid Pro export format 2026-06-25 14:52:11 +03:00
README.md chore(tickets): hand the tickets schema + ingest to the fleettickets repo 2026-06-11 20:15:23 +03:00

tools/ — manual & one-shot operator scripts

These are not part of the running stack (no service executes them). They are manual utilities, mostly one-shot tasks that have already been run. Kept here for reference and the occasional re-run, out of the production root.

They import ts_shared_rev (DB pool, API client, clean helpers) from the repo root, so run them as modules from the image root (/app), not as bare files:

WK=$(docker ps --filter name=ingest_worker --format "{{.Names}}" | head -1)
docker exec -it "$WK" python -m tools.<name> [args]
Script What it does One-shot?
sync_driver_audit.py API↔DB driver/IMEI gap report + full device upsert across all sub-accounts re-runnable audit
audit_device_reconciliation.py Read-only: reconcile the vehicle CSV (data/) against tracksolid.devices; reports gaps + NULL fields re-runnable audit
import_drivers_csv.py Populate device names/plates from CSV (--apply to commit). The registry is already populated — kept for future bulk re-imports one-shot (done)
backfill_trips_enrichment.py One-shot backfill of historical tracksolid.trips (route_geom/addresses/plate) for rows predating migration 09 (--apply to commit) one-shot (done)

INC/CRQ ticket ingestion (import_tickets.py) moved to its own repo — repo.rahamafresh.com/kianiadee/fleettickets.git.

data/ holds the source CSVs the import/audit scripts read (default: data/20260427_FSG_Vehicles_mitieng.csv).