mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(maps): say which source answered, and stop the stubs driving the index
Two halves of one mistake, both found by the suite. Letting each side of the merged search catch its own failure meant the index could contribute nothing while the answer still called itself "trek-places+openstreetmap". That label is not decoration: the search log writes it into the corpus a candidate index gets scored against later, so a list that is entirely OpenStreetMap must not be recorded as though the index had a hand in it. The source now names what actually contributed. And maps.service.test.ts drove the index for real. Its fetch stubs answer with json() and no text(), which is not what the index client reads, so the branch was entered and then failed on the stub — "uses Nominatim when user has no API key" was really testing that a stub is incomplete. With the new circuit breaker those failures also accumulated, and the breaker is process state, so it leaked into whatever file ran next. trekPlacesSearch is stubbed there now, beside the nearby stub that was already there for the same reason. The index paths keep their own files.
This commit is contained in:
@@ -1697,10 +1697,16 @@ export class MapsService {
|
||||
osmAnswer = osm;
|
||||
const places = mergeSearchResults(found.map(toPlaceRecord), osm);
|
||||
if (places.length > 0) {
|
||||
return {
|
||||
places,
|
||||
source: osm.length > 0 ? 'trek-places+openstreetmap' : 'trek-places',
|
||||
};
|
||||
// Names the sources that actually contributed, not the ones that were
|
||||
// asked. Either side can come back empty — the index turns down a common
|
||||
// single word without coordinates, and OpenStreetMap can be down — and
|
||||
// the search log writes this into the corpus a candidate index is later
|
||||
// scored against, so a list that is entirely OpenStreetMap must not be
|
||||
// recorded as though the index had a hand in it.
|
||||
const source = found.length > 0
|
||||
? (osm.length > 0 ? 'trek-places+openstreetmap' : 'trek-places')
|
||||
: 'openstreetmap';
|
||||
return { places, source };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user