feat: manual odometer baseline — Settings field computes baseline + trip distance, Dashboard shows (manual) label

This commit is contained in:
Mathieu Moran
2026-08-11 18:51:11 -04:00
parent 887a001723
commit 34253b3ffb
7 changed files with 58 additions and 30 deletions
+6 -1
View File
@@ -457,6 +457,10 @@ def get_overview_stats():
video_count = sum(1 for _ in _av.list_local_videos().get("files", []))
except Exception:
video_count = 0
from modules import app_settings
base = app_settings._number_value("odometer_baseline", float, 0)
cumul = conn.execute("SELECT COALESCE(SUM(DISTANCE_KM), 0) FROM trips").fetchone()
computed = base + (cumul[0] if cumul else 0)
return {
"trip_count": row[0],
"total_km": row[1],
@@ -464,7 +468,8 @@ def get_overview_stats():
"all_time_max_speed": row[3],
"active_dtc": dtc_row[0] if dtc_row else 0,
"video_count": video_count,
"odometer_km": odo_row[0] if odo_row and odo_row[0] else None,
"odometer_km": computed if base > 0 else (odo_row[0] if odo_row and odo_row[0] else None),
"odometer_source": "manual" if base > 0 else "obd",
}