mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(osm): keep a capped place list incomplete in analyst follow-ups
osm_query said "At least N" when the server capped its list, but handed the places to the analyst engine with truncated:false, so "which of those have emergency?" answered as if the list were whole. The handoff now carries the cap and its caveat, and follow-ups (and their follow-ups) stay incomplete with an unknown total.
This commit is contained in:
1 parent
4efba8ccca
commit
540629a0fc
6 files changed
+99
-20
No files matched your search
@@ -8,6 +8,7 @@ import { boxDeg2, osmQuery } from './osmActions.js';
|
||||
import { matchOsmPreset, OSM_PRESET_IDS } from '../data/osmPresets.js';
|
||||
import { createAreaStore } from '../data/areaStore.js';
|
||||
import { dedupeOsmRecords, mapOsmFeature } from '../layers/osmPlaces/model.js';
|
||||
import { createAnalystEngine } from '../data/analystEngine.js';
|
||||
|
||||
const square = (w, s, e, n) => [
|
||||
[w, s],
|
||||
@@ -346,6 +347,51 @@ test('a truncated list reports at least N', async () => {
|
||||
assert.match(result.say, /^At least 1 hospital in Kathmandu/);
|
||||
});
|
||||
|
||||
test('a capped list stays incomplete through analyst follow-ups', async () => {
|
||||
// Wired as gevActions wires it: the listed places become the last answer.
|
||||
const run = async (truncated) => {
|
||||
const { value } = deps({
|
||||
answer: { ok: true, features: FEATURES.slice(2, 3), truncated },
|
||||
});
|
||||
const records = [];
|
||||
const engine = createAnalystEngine({
|
||||
getRecords: (key) => (key === 'osm-places' ? records : []),
|
||||
resolveRegionRing: async () => null,
|
||||
getViewContext: () => ({ lat: 27.7, lon: 85.3, viewRadiusKm: 20 }),
|
||||
});
|
||||
value.rememberResults = (rows, presentation, options) => {
|
||||
records.splice(0, records.length, ...rows);
|
||||
engine.remember('osm-places', rows, { presentation, ...options });
|
||||
};
|
||||
const first = await osmQuery(value, {
|
||||
what: 'hospitals',
|
||||
areaId: 'osm:r1',
|
||||
limit: 1,
|
||||
});
|
||||
const followUp = await engine.query({
|
||||
layers: ['osm-places'],
|
||||
followUp: true,
|
||||
filters: [{ field: 'emergency', op: 'eq', value: 'yes' }],
|
||||
});
|
||||
// And a follow-up of the follow-up.
|
||||
const again = await engine.query({ layers: ['osm-places'], followUp: true });
|
||||
return { first, followUp, again };
|
||||
};
|
||||
const capped = await run(true);
|
||||
assert.equal(capped.first.complete, false);
|
||||
assert.equal(capped.followUp.ok, true);
|
||||
assert.equal(capped.followUp.count, 1);
|
||||
assert.equal(capped.followUp.complete, false, 'the count is a floor');
|
||||
assert.equal(capped.followUp.display.caveat, 'listed the first 1; there are more');
|
||||
assert.equal(capped.followUp.scopeLabel, 'inside Kathmandu');
|
||||
assert.equal(capped.again.complete, false);
|
||||
assert.equal(capped.again.display.caveat, 'listed the first 1; there are more');
|
||||
|
||||
const whole = await run(false);
|
||||
assert.equal(whole.first.complete, true);
|
||||
assert.equal(whole.followUp.complete, true);
|
||||
});
|
||||
|
||||
test('spoken kinds map to curated presets', () => {
|
||||
assert.equal(matchOsmPreset('all hospitals').id, 'hospital');
|
||||
assert.equal(matchOsmPreset('petrol stations').id, 'fuel');
|
||||
|
||||
Reference in new issue
Block a user