fix(traffic): flag stale cached TomTom tiles in get_traffic_flow (#1239)

Report stale traffic tiles and their fetch time, and release pending freshness metadata when tile requests fail or are cancelled.

Contribution by @quanticsoul4772.
This commit is contained in:
quanticsoul4772 authored and GitHub committed 2026-10-25 08:26:26 -07:00
1 parent f6e7f63a63
commit 6bbf9b94c4
8 files changed
+299 -18

No files matched your search

+11
View File
@@ -473,11 +473,22 @@ export const getTrafficFlow = defineTool({
: `No live traffic is reported in ${area.label}.`) +
(flow.partial
? ' Some map tiles did not load, so these figures are partial.'
: '') +
// Past the daily TomTom budget, or while TomTom fails, the proxy
// serves its last copy of a tile however old it is.
(flow.stale
? ' Some tiles are cached copies' +
(isoTime(flow.oldestTileAt)
? `, the oldest from ${isoTime(flow.oldestTileAt)}`
: '') +
', so traffic may be out of date.'
: ''),
data: {
view: suggestView(services, { area, layers: ['traffic'] }),
area: area.label,
partial: flow.partial,
stale: flow.stale === true,
oldest_tile_at: isoTime(flow.oldestTileAt),
speed_pct_of_free_flow: speedPct,
measured_km: round(measuredKm, 1),
congested_km: round(congestedKm, 1),