mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
fix: keep each aircraft feed's freshness in search answers
find_aircraft merged the records of the feeds that answered and dropped their freshness, so a stale OpenSky snapshot read as a current "not reported". Answers now list each feed with its freshness and coverage and say which feed's data may be stale.
This commit is contained in:
1 parent
41d1352930
commit
33445aec73
2 files changed
+55
-1
No files matched your search
@@ -351,3 +351,40 @@ test('a regional fallback feed is named in the answer', async () => {
|
||||
});
|
||||
assert.match(result.summary, /\(regional feed: 250nm regional fallback\)\.$/);
|
||||
});
|
||||
|
||||
test('aircraft searches say when a feed that answered is stale', async () => {
|
||||
const stale = feed([], { freshness: 'stale' });
|
||||
const result = await composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { aircraft: stale, military: feed([]) },
|
||||
}).call('find_aircraft', { callsign: 'UAL1' });
|
||||
assert.equal(
|
||||
result.summary,
|
||||
'No aircraft with callsign UAL1 is currently reported. The civil feed data may be stale.',
|
||||
);
|
||||
assert.deepEqual(result.data.stale_feeds, ['civil']);
|
||||
assert.deepEqual(
|
||||
result.data.feeds.map((entry) => [entry.feed, entry.freshness]),
|
||||
[
|
||||
['civil', 'stale'],
|
||||
['military', 'current'],
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('the real OpenSky source marks an hour-old snapshot stale for searches', async () => {
|
||||
const { createOpenSkySource } =
|
||||
await import('../../sources/live/standalone.js');
|
||||
const now = Date.UTC(2026, 0, 1, 12);
|
||||
const opensky = createOpenSkySource({
|
||||
now: () => now,
|
||||
fetchImpl: async () =>
|
||||
Response.json({ time: now / 1000 - 3600, states: [] }),
|
||||
});
|
||||
const result = await composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { aircraft: opensky },
|
||||
}).call('find_aircraft', { callsign: 'UAL1' });
|
||||
assert.deepEqual(result.data.stale_feeds, ['civil']);
|
||||
assert.match(result.summary, /may be stale\.$/);
|
||||
});
|
||||
Reference in new issue
Block a user