Commit graph

4 commits

Author SHA1 Message Date
kianiadee
7d63c03191 Trip detection: add nofix_stop rule (5-min reporting silence ends trip)
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Calibrated against a full-day legacy report for vehicle KDE 638J:
without this rule we collapsed 15 dispatcher-visible trips into 3
(the algorithm waited for explicit ACC_OFF + stationary fixes that never
came in the polled data — the device just stops reporting between trips).

New rule: if mid-trip and the next fix arrives >=5 min after the previous
one (but <=30 min, which is still long_gap), close the trip at the prior
fix with end_reason='nofix_stop'.

Validation:
  638J full day: legacy 15 trips, mine 15 trips, perfect alignment
  728K half day: legacy 33 noisy trips, mine 9 clean trips
                 (stop-and-go traffic still consolidates because fixes
                  keep coming, just slow/stationary — not silence)

Also commits scripts/simulate_trips_from_legacy.py which runs the same
state machine in Python against REPORTS/*.json dumps for offline tuning.
2026-05-27 12:57:01 +03:00
kianiadee
495bb2bd71 Rollback CSV roster import (mig 17): re-split vehicles, drop CSV columns
Some checks failed
build / lint-test (push) Has been cancelled
build / build-push (push) Has been cancelled
The CSV-based roster import (mig 15+16 and scripts/import_csv_roster.py)
merged vehicle rows that differed only by _Track / _CAM suffix, dropping
the active fleet count from 144 to 124. Reverting the whole thing.

Mig 17 in one transaction:
  - Re-splits devices by parsed plate from device_name (same regex as
    mig 14, preserving _Track as separate vehicle)
  - Restores serve.fn_live_view to its v3 body (no d.driver_name/phone
    refs that would break once the columns are gone)
  - Drops the six CSV-only columns from domain.devices
  - Deletes schema_migrations rows for the deleted 15/16
  - Logs final counts via RAISE NOTICE

Apply on VPS: psql -f db/migrations/20260601000017_rollback_csv_import.sql
2026-05-25 00:41:32 +03:00
kianiadee
4cc0ef0535 Roster import: COALESCE-fill API-managed fields (device_type/lifecycle/activation_at/model) on existing rows; CSV is authoritative only for driver/phone/iccid/expiration/device_group
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-24 03:59:32 +03:00
kianiadee
1fb2a5be5e Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00