mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Preserve positionless aircraft identities for classification
This commit is contained in:
1 parent
1edebcb6f8
commit
22138212b9
8 files changed
+99
-4
No files matched your search
@@ -129,10 +129,17 @@ export function createMilitaryRegistry({ source, now = Date.now } = {}) {
|
||||
const signal = AbortSignal.any([owner.signal, AbortSignal.timeout(10000)]);
|
||||
_polling = true;
|
||||
try {
|
||||
const snapshot = await requestSource.getSnapshot({}, { signal });
|
||||
const ids =
|
||||
typeof requestSource.getIdentities === 'function'
|
||||
? await requestSource.getIdentities({}, { signal })
|
||||
: (await requestSource.getSnapshot({}, { signal })).records.map(
|
||||
(record) => record.id,
|
||||
);
|
||||
signal.throwIfAborted();
|
||||
if (lifetime !== owner) return;
|
||||
registerMilitaryIcaos(snapshot.records.map((record) => record.id));
|
||||
if (!Array.isArray(ids))
|
||||
throw new TypeError('Expected aircraft identities');
|
||||
registerMilitaryIcaos(ids);
|
||||
} catch {
|
||||
// Keep the existing classification through source outages.
|
||||
} finally {
|
||||
|
||||
@@ -121,3 +121,21 @@ test('disposing a registry fed directly by its layer also clears classification'
|
||||
registry.dispose();
|
||||
assert.equal(registry.isMilitaryIcao('abc123'), false);
|
||||
});
|
||||
|
||||
test('classification prefers an explicit identity capability over positioned observations', async () => {
|
||||
const registry = createMilitaryRegistry({
|
||||
source: {
|
||||
getSnapshot() {
|
||||
assert.fail(
|
||||
'position snapshots must not replace an available identity capability',
|
||||
);
|
||||
},
|
||||
async getIdentities() {
|
||||
return ['abc123'];
|
||||
},
|
||||
},
|
||||
});
|
||||
await registry.refreshMilitaryRegistryIfStale();
|
||||
assert.equal(registry.isMilitaryIcao('abc123'), true);
|
||||
registry.dispose();
|
||||
});
|
||||
Reference in new issue
Block a user