feat: manual odometer baseline — Settings field computes baseline + trip distance, Dashboard shows (manual) label
This commit is contained in:
+6
-1
@@ -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",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user