Commit graph

4 commits

Author SHA1 Message Date
kianiadee
1bf7e63c62 feat(schema): standardize fuel timestamps to Africa/Nairobi (EAT)
Source feed is UTC ("…Z"); the fleet is in Kenya (UTC+3). Storing UTC timestamptz
made record_datetime::date bucket by UTC day. Migration 03 converts record_datetime,
deleted_at, ingested_at, updated_at (+ ingest_state.updated_at) to Africa/Nairobi
wall-clock `timestamp`, updates the trigger to derive EAT, recreates the views
(fuel_date now EAT day) and re-grants grafana_ro. Verified in prod: 18:38Z -> 21:38 EAT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 23:58:27 +03:00
kianiadee
a5380aece6 fix(schema): one device per fill in v_fuel_fills (LATERAL + LIMIT 1)
A plate can map to multiple tracksolid.devices rows (vehicle re-fitted with a
new tracker), so the plain LEFT JOIN fanned out and double-counted litres/spend
(3345 view rows for 1888 live records). LATERAL ... ORDER BY enabled_flag,
updated_at LIMIT 1 picks one device per fill. Applied to prod as migration 02;
01 updated so fresh installs are correct. Verified: 1888 rows, 1775 matched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 23:49:37 +03:00
kianiadee
42e3ed7c50 docs: add deployment.html (architecture flow diagram + runbook)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 23:38:11 +03:00
kianiadee
9943932200 Initial fleetfuel: rustfs fuel bucket → DB → FleetOps Fuel Log
Self-contained ingestion module (mirrors fleettickets) for the WhatsApp
fuel-record feed in the rustfs `fuel` bucket:

- import_fuel.py — snapshot/changes/file modes, raw-jsonb upsert on id
- migrations/01_fuel_schema.sql — fuel schema, plate/fuel-type/department
  normalizers, trigger-derived columns, reporting.v_fuel_fills +
  v_fuel_efficiency, grafana_ro grants
- s3util.py / shared.py / run_migrations.py — rustfs client + DB helpers
- docs/plan.html — implementation plan

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 23:24:33 +03:00