feat: odometer in trips/overview, trips upload toggle, fix video count

- OBD odometer now logged to tracking rows on every GPS snapshot
- trips table: START_ODOMETER/END_ODOMETER columns (migration)
- build_trip_summaries: picks odometer from first/last tracking row
- list_trips: uses real OBD odo, falls back to cumulative distance
- overview stats: odometer_km (max seen from OBD), video_count fixed
- history page: Odometer column shows start→end km per trip
- app_upload: TRIPS_UPLOAD_SETTING_KEY, is_trips_upload_enabled()
- _upload_tracking_batch: skips when trips upload is off
- settings: separate 'Upload trips & GPS' toggle from dashcam toggle

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 02:07:31 -04:00
co-authored by Copilot
parent 414fb78543
commit afce229310
9 changed files with 80 additions and 21 deletions
+8
View File
@@ -66,6 +66,7 @@ BACKOFF_MAX = 300
DASHCAM_CHUNK_SIZE = 40 * 1024 * 1024
DASHCAM_UPLOAD_SETTING_KEY = "dashcam_upload_enabled"
TRIPS_UPLOAD_SETTING_KEY = "trips_upload_enabled"
_upload_thread = None
_last_error = None
@@ -90,6 +91,11 @@ def set_dashcam_upload_enabled(enabled):
app_sql.set_setting(DASHCAM_UPLOAD_SETTING_KEY, "1" if enabled else "0")
def is_trips_upload_enabled():
"""Defaults to enabled."""
return app_sql.get_setting(TRIPS_UPLOAD_SETTING_KEY, "1") == "1"
def get_status():
"""Snapshot used by the /api/upload/status endpoint for the web UI."""
return {
@@ -138,6 +144,8 @@ def _upload_tracking_batch():
modem's AT-command HTTP client before giving up.
"""
global _last_network_path
if not is_trips_upload_enabled():
return 0
rows = app_sql.get_unsent_tracking_rows(limit=TRACKING_BATCH_SIZE)
if not rows: