mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
f6e7f63a63
commit
6bbf9b94c4
8 files changed
+299
-18
No files matched your search
@@ -555,6 +555,47 @@ test('traffic counts only roads inside a radius area and reports missing tiles',
|
||||
assert.match(partial.summary, /Some map tiles did not load/);
|
||||
});
|
||||
|
||||
test('traffic says when the proxy served cached tiles, and how old the oldest is', async () => {
|
||||
const road = [
|
||||
{
|
||||
coords: [
|
||||
[-0.2, 0],
|
||||
[0.2, 0],
|
||||
],
|
||||
trafficLevel: 0.9,
|
||||
},
|
||||
];
|
||||
const call = (detail) =>
|
||||
composeCatalog({
|
||||
tools: coreTools,
|
||||
services: {
|
||||
traffic: {
|
||||
getStatus: async () => ({ hasKey: true }),
|
||||
fetchFlowDetail: async () => ({
|
||||
segments: road,
|
||||
partial: false,
|
||||
...detail,
|
||||
}),
|
||||
},
|
||||
},
|
||||
}).call('get_traffic_flow', { area: { lat: 0, lon: 0, radius_km: 10 } });
|
||||
const oldest = Date.UTC(2026, 9, 16, 8);
|
||||
const stale = await call({ stale: true, oldestTileAt: oldest });
|
||||
assert.equal(stale.data.stale, true);
|
||||
assert.equal(stale.data.oldest_tile_at, '2026-10-16T08:00:00.000Z');
|
||||
assert.match(
|
||||
stale.summary,
|
||||
/cached copies, the oldest from 2026-10-16T08:00:00\.000Z, so traffic may be out of date\./,
|
||||
);
|
||||
const live = await call({ stale: false, oldestTileAt: oldest });
|
||||
assert.equal(live.data.stale, false);
|
||||
assert.doesNotMatch(live.summary, /out of date/);
|
||||
// A source that can't tell (no freshness fields) isn't reported as stale.
|
||||
const unknown = await call({});
|
||||
assert.equal(unknown.data.stale, false);
|
||||
assert.equal(unknown.data.oldest_tile_at, null);
|
||||
});
|
||||
|
||||
test('a whole-world bike-share search names every system it skipped', async () => {
|
||||
const empty = { data: { stations: [] } };
|
||||
const result = await composeCatalog({
|
||||
|
||||
Reference in new issue
Block a user