From 1fefd72e884296f7a4454d3534f5bcc3ac3e2299 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 12 Nov 2025 19:35:34 +0100 Subject: respect track date when downgrading --- fietsboek/updater/scripts/upd_20251109_nm561argcq1s8w27.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fietsboek/updater/scripts/upd_20251109_nm561argcq1s8w27.py b/fietsboek/updater/scripts/upd_20251109_nm561argcq1s8w27.py index 05a7233..e3e5e47 100644 --- a/fietsboek/updater/scripts/upd_20251109_nm561argcq1s8w27.py +++ b/fietsboek/updater/scripts/upd_20251109_nm561argcq1s8w27.py @@ -108,13 +108,17 @@ class Down(UpdateScript): connection = engine.connect() data_dir = Path(config["fietsboek.data_dir"]) - query = text("SELECT id, title, description FROM tracks;") + query = text("SELECT id, title, description, date_raw FROM tracks;") for row in connection.execute(query): gpx = gpxpy.gpx.GPX() gpx.description = row.description gpx.name = row.title + start_date = row.date_raw + if isinstance(start_date, str): + start_date = datetime.datetime.fromisoformat(start_date) + segment = gpxpy.gpx.GPXTrackSegment() points_query = text(""" SELECT longitude, latitude, elevation, time_offset @@ -126,9 +130,7 @@ class Down(UpdateScript): latitude=point.latitude, longitude=point.longitude, elevation=point.elevation, - # This is wrong, should take proper track start time - # into account: - time=datetime.datetime.fromtimestamp(point.time_offset), + time=start_date + datetime.timedelta(seconds=point.time_offset), ) ) track = gpxpy.gpx.GPXTrack() -- cgit v1.2.3