Summarize LiveTrack sessions and prune stale ones
CI / check (push) Successful in 48s
CI / deploy (push) Successful in 23s

Fetching a session's track now also grabs its summary (name, activity
type, distance, duration) from the same page and stores it — sessions
the panel has actually shown replace their raw UUID with that summary,
and are kept indefinitely regardless of age. A session nobody ever
opened (no summary) is more likely test/dead data than something worth
keeping, so it's dropped automatically after 48h.
This commit is contained in:
randy committed 2026-09-06 22:18:25 +02:00
1 parent f4b5237f01
commit 0ee98d8f07
5 files changed
+175 -47

No files matched your search

+3 -1
View File
@@ -254,11 +254,13 @@ module Maptool
halt 404, json(error: "session has no token") if session["token"].to_s.empty?
begin
points = LiveTrackClient.track_points(session["id"], session["token"])
result = LiveTrackClient.fetch(session["id"], session["token"])
rescue LiveTrackClient::FetchError => e
halt 502, json(error: "could not fetch track: #{e.message}")
end
LIVETRACK_STORE.set_summary(session["id"], LiveTrackClient.summarize(result))
points = result.points
coordinates = points.filter_map { |p| p.dig("position", "lon") && p.dig("position", "lat") && [p["position"]["lon"], p["position"]["lat"]] }
halt 502, json(error: "track has no positions") if coordinates.empty?
last = points.last