Commit graph

15 commits

Author SHA1 Message Date
kianiadee
e89d8ed821 Continuous day-track line under per-trip segments
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Trip days split on reporting gaps rendered as disconnected coloured segments. Add serve.fn_vehicle_day_track (one primary-device LineString for the EAT day), merge it into the trips API as day_track, and draw it as a faint base line beneath the per-trip colours so the route reads as one continuous drive.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 10:31:52 +03:00
kianiadee
84e9421b4d Self-host MapLibre; de-dupe position_history
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
- Vendor maplibre-gl 4.7.1 (js+css) and serve from /vendor instead of the unpkg CDN — no external dependency/SRI gap for the core map.

- Projector skips duplicate (imei, occurred_at) history rows via NOT EXISTS (parked devices re-report the same gpsTime each poll); migration 23 dedupes existing rows and adds a unique index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 03:41:34 +03:00
kianiadee
cf747d3efe Fix CI lint failures so build-push can run and push an image
Some checks failed
build / build-push (push) Blocked by required conditions
build / lint-test (push) Failing after 6s
ruff: drop stale SLF001 noqa, wrap json.load in a context manager (SIM115), remove unused imports + placeholder-less f-strings; ignore PLR0912/PLR0915 for one-off scripts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 01:11:19 +03:00
kianiadee
9c7b69e395 P1-b: don't let LBS/WIFI fixes overwrite a fresh GPS fix in live view
Some checks are pending
build / build-push (push) Blocked by required conditions
build / lint-test (push) Waiting to run
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 00:13:55 +03:00
kianiadee
6eb6b4716c Fix camera/tracker dedup (device_type at provision + backfill) and finish refresh-token flow
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 00:08:56 +03:00
kianiadee
419c030761 Trip detection backend: serve.fn_vehicle_trips + JSON/CSV endpoints
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
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
kianiadee
0f91668256 Contract checker (#13, PRD F1.10) + contract_drift_days SLO
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
Migration 18: ops.contract_check_log table — append-only log of probes
against the Tracksolid Pro endpoints we depend on.

New worker app/workers/contract_check.py — per run:
  - jimi.oauth.token.get   (token refresh succeeds)
  - jimi.user.device.location.list per configured target (parse first item
    with JimiPollFix)
  - jimi.device.location.get with a sample IMEI from the list (parse first
    item with JimiPollFix)
Each probe logs success or {error_class, error_detail, sample}; failures
are recorded, not raised.

slo_metrics now also computes contract_drift_days = days since the most-
recent successful probe of the laggard endpoint. With threshold 1d (from
mig 5), a single failed daily run flips the badge red within 24h.

cron entrypoint registers the check daily at 02:00 UTC plus once on
startup, gated on TRACKSOLID_APP_KEY + a configured target.
2026-05-27 11:58:29 +03:00
kianiadee
6fd0d84560 Plate consolidation migration + projector links new devices to existing plates; SLO measurement worker (task #12)
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 23:42:45 +03:00
kianiadee
45974b3810 Geocoder: cron job + state.geocoded_positions; label uses device_name last 4 (fallback plate); popup address row
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 23:06:25 +03:00
kianiadee
6c5ba3b22b UI: arrow + plate-short label + cost-centre marker palette + hover popup; richer state.live_positions + serve.fn_live_view v2; multi-target poll plumbing
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 09:29:04 +03:00
kianiadee
13a4c17d80 Parser: tolerate real Tracksolid wire shape (imei/speed names, null gpsTime for offline devices) + per-item resilience
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 09:05:17 +03:00
kianiadee
4924552c7f Add Tracksolid polling worker + auto-provisioning projector + result-key parser support
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 08:59:27 +03:00
kianiadee
6dcfaffb7c Gateway: serve web/ at root via StaticFiles; redirect / to /index-live.html
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 01:35:13 +03:00
kianiadee
0fb24a8ade listener: use psycopg notifies(timeout=) instead of wait_for(anext()) to fix spurious StopAsyncIteration
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions
2026-05-23 01:20:43 +03:00
kianiadee
1fb2a5be5e Phase 1 — foundation, push gateway, parser, projector, live view, frontend 2026-05-23 00:53:42 +03:00