mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
fix(map): ask Valhalla again for days drawn by OSRM only while the relay rested
The OSRM stand-in is kept only for a day Valhalla was asked and could not route, so a short rest or an offline session no longer keeps other days on OSRM for an hour.
This commit is contained in:
@@ -317,8 +317,8 @@ async function valhallaOrOsrmDay(
|
||||
const plain = (await storedRoute(keys.plain)) ?? await osrmWithLegs(waypoints, keys.coords, profile, signal)
|
||||
cacheRoute(keys.plain, plain)
|
||||
const drawn = withFallbackNoted(plain, avoiding)
|
||||
// A day left before Valhalla answered was never refused by it.
|
||||
if (standInKey && !signal?.aborted) keepStandIn(standInKey, drawn)
|
||||
// A day left before Valhalla answered, or never put to it, was not refused by it.
|
||||
if (standInKey && asking && !signal?.aborted) keepStandIn(standInKey, drawn)
|
||||
return drawn
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +314,21 @@ describe('the route cache keeps the engine apart', () => {
|
||||
});
|
||||
|
||||
describe('the route cache while the relay rests', () => {
|
||||
it('VDAY-CACHE-006: a day drawn by OSRM while the relay rested is asked again as soon as it is back', async () => {
|
||||
let up = false;
|
||||
const traffic = listen((body) => (up ? answered(body) : HttpResponse.json({ error: 'down' }, { status: 503 })));
|
||||
await calculateRouteWithLegs(freshDay(2), { profile: 'driving' });
|
||||
const points = freshDay(3);
|
||||
expect((await calculateRouteWithLegs(points, { profile: 'driving' })).engine).toBe('osrm');
|
||||
expect(traffic.relay).toHaveLength(1);
|
||||
|
||||
up = true;
|
||||
resetValhallaTurns();
|
||||
const routed = await calculateRouteWithLegs(points, { profile: 'driving' });
|
||||
expect([routed.distance, routed.engine]).toEqual([4000, 'valhalla']);
|
||||
expect(traffic.relay).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('VDAY-CACHE-003: a day kept from Valhalla is still found while the relay rests, as it is offline', async () => {
|
||||
const points = freshDay(3);
|
||||
let up = true;
|
||||
|
||||
Reference in New Issue
Block a user