mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
fix: search every vessel the server retains
Vessel tools read the source's default of the newest 12,000 vessels while the server keeps up to 50,000, so a lookup could miss a vessel still held. They now ask for more than any server keeps and receive everything it has.
This commit is contained in:
1 parent
ad9a3976a9
commit
41d1352930
2 files changed
+34
-2
No files matched your search
@@ -2,6 +2,8 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { composeCatalog, coreTools } from '../index.js';
|
||||
import { LiveSourceError } from '../../sources/live/contract.js';
|
||||
import { createAisStreamSource } from '../../sources/live/standalone.js';
|
||||
import { AISSTREAM_CACHE_MAX } from '../../../server/providers/vessels/ais-store.js';
|
||||
|
||||
const vessel = (id, latitude, longitude, extra = {}) => ({
|
||||
id,
|
||||
@@ -179,3 +181,23 @@ test('a missing AIS key surfaces as an unavailable feed', async () => {
|
||||
error.message === 'AISSTREAM_API_KEY not set',
|
||||
);
|
||||
});
|
||||
|
||||
test('vessel searches ask for every vessel the server retains', async () => {
|
||||
const requested = [];
|
||||
const source = createAisStreamSource({
|
||||
origin: () => 'http://localhost',
|
||||
fetchImpl: async (url) => {
|
||||
requested.push(new URL(url).searchParams.get('maxRows'));
|
||||
return Response.json({ rows: [], source: 'AISStream', status: 'live' });
|
||||
},
|
||||
});
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { vessels: source },
|
||||
});
|
||||
await catalog.call('find_vessel', { mmsi: '366999712' });
|
||||
await catalog.call('vessels_in_area', { area: bay });
|
||||
assert.equal(requested.length, 2);
|
||||
for (const maxRows of requested)
|
||||
assert.ok(Number(maxRows) >= AISSTREAM_CACHE_MAX, maxRows);
|
||||
});
|
||||
Reference in new issue
Block a user