fleet-platform/app
kianiadee 419c030761
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Trip detection backend: serve.fn_vehicle_trips + JSON/CSV endpoints
Migration 19: serve.fn_vehicle_trips(vehicle_id, date) — PL/pgSQL state
machine that walks state.position_history for one vehicle on one EAT day
and emits the trip breakdown. Rules:

  - reporting_time = first ACC_ON of the day
  - trip starts at ACC_ON (or first fix if already ACC_ON / moving)
  - trip ends:
      * ACC_OFF + stationary (<5 km/h) for >=5 min  → end_reason 'work_stop'
      * fix gap >30 min                              → end_reason 'long_gap'
      * end of day's data                            → end_reason 'day_end'
  - within a trip, ACC_ON + stationary >=5 min is logged as an idling
    segment (no trip split — engine still on)
  - distance only accumulates when speed >= 5 km/h (excludes GPS jitter)
  - falls back to movement-only segmentation when acc_state is null
    across the day (has_acc_data=false in the response)

Returns one jsonb document: vehicle, date, reporting_time, day totals
(distance, driving/idling/stopped/unknown minutes), data_quality flags,
trips[] with start/end/duration/distance/idling/end_reason/stops/path
where path is a GeoJSON LineString ready for the map.

New endpoints (read:fleet, rate-limited):
  GET /api/views/vehicle/{id}/trips?date=YYYY-MM-DD       JSON
  GET /api/views/vehicle/{id}/trips.csv?date=YYYY-MM-DD   one row per trip

Defaults date to today in EAT (UTC+3) regardless of host TZ.
2026-05-27 12:24:00 +03:00
..
entrypoints Contract checker (#13, PRD F1.10) + contract_drift_days SLO 2026-05-27 11:58:29 +03:00
models Parser: tolerate real Tracksolid wire shape (imei/speed names, null gpsTime for offline devices) + per-item resilience 2026-05-23 09:05:17 +03:00
parsers UI: arrow + plate-short label + cost-centre marker palette + hover popup; richer state.live_positions + serve.fn_live_view v2; multi-target poll plumbing 2026-05-23 09:29:04 +03:00
projectors Plate consolidation migration + projector links new devices to existing plates; SLO measurement worker (task #12) 2026-05-23 23:42:45 +03:00
routers Trip detection backend: serve.fn_vehicle_trips + JSON/CSV endpoints 2026-05-27 12:24:00 +03:00
tracksolid Add Tracksolid polling worker + auto-provisioning projector + result-key parser support 2026-05-23 08:59:27 +03:00
workers Contract checker (#13, PRD F1.10) + contract_drift_days SLO 2026-05-27 11:58:29 +03:00
__init__.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00
auth.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00
config.py Geocoder: cron job + state.geocoded_positions; label uses device_name last 4 (fallback plate); popup address row 2026-05-23 23:06:25 +03:00
db.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00
health.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00
logging_setup.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00
main.py Gateway: serve web/ at root via StaticFiles; redirect / to /index-live.html 2026-05-23 01:35:13 +03:00
rate_limit.py Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00