Flag LiveTrack sessions whose map Garmin no longer serves
CI / check (push) Successful in 42s
CI / deploy (push) Successful in 20s

Ended sessions past the ~24h Garmin appears to keep a live-track page
around for get verified once at app startup and, once confirmed dead,
flagged so the panel greys them out instead of only failing after a
click. Already-flagged sessions are skipped on later startups so this
doesn't keep re-hitting Garmin for the same dead session.
This commit is contained in:
randy committed 2026-09-08 14:19:15 +02:00
1 parent 141b7a08ce
commit 0c4ee97368
5 files changed
+98 -3

No files matched your search

+19
View File
@@ -325,6 +325,25 @@ module Maptool
json sessions: LIVETRACK_STORE.list
end
# Garmin stops serving a session's live-track page some while after the
# activity ends (its own session/token URL, not the API — see
# LiveTrackClient) — the exact cutoff isn't documented, ~24h is what's
# been observed. Ended sessions old enough to likely be past that are
# verified once at startup (LiveTrackStore#stale_ended already skips
# ones already flagged, so this doesn't re-hit Garmin for the same
# dead session on every restart), so the panel can grey them out up
# front instead of only failing after a user clicks one and waits on
# a fetch.
LIVETRACK_MAP_STALE_AFTER = 24 * 60 * 60 # seconds
Thread.new do
LIVETRACK_STORE.stale_ended(LIVETRACK_MAP_STALE_AFTER).each do |session|
LiveTrackClient.fetch(session["id"], session["token"])
rescue LiveTrackClient::FetchError
LIVETRACK_STORE.mark_unavailable(session["id"])
end
end
# Garmin's own API (livetrack.garmin.com/api/v2/...) 403s a plain server
# request no matter what headers it gets — see LiveTrackClient — so this
# fetches the session page itself and pulls the track out of that.