mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(tours): count a multi-day tour in the activity sums only once all its stages are on days
The activity sums never read which stage a day holds, so a multi-day tour counted its whole route on the last dated stage day while other stages were on no day yet, and a recording on one stage took the place of the whole plan beside it. With stages on days of their own, the route now counts once every stage is on a dated day of the user's, on the last of them, and is uncounted until then; a recording counts as what was done and the plan is not added beside it.
This commit is contained in:
@@ -84,6 +84,7 @@ describe('TourActivitiesRepository stats reads (STA-02)', () => {
|
||||
derived_from_place_id: null,
|
||||
trip_id: trip.id,
|
||||
trip_title: 'Alps',
|
||||
tour_stage_key: null,
|
||||
participant_count: 1,
|
||||
joined: 0,
|
||||
});
|
||||
@@ -126,4 +127,12 @@ describe('TourActivitiesRepository stats reads (STA-02)', () => {
|
||||
expect(await repo.listTracksForStats([theirs.id])).toEqual([]);
|
||||
expect(await repo.listTracksForStats([])).toEqual([]);
|
||||
});
|
||||
|
||||
it('STA2-REPO-014: names the stage a day holds of a multi-day tour, and none for a day that holds the whole tour', async () => {
|
||||
const { user, trip, day, hike, onDay } = await fixture();
|
||||
const onStage = await makeDayAssignment(t, day.id, hike.id, { tour_stage_key: 'hut-1' });
|
||||
const rows = await repo.listExecutionsForStats([trip.id], user.id);
|
||||
expect(rows.find((row) => row.assignment_id === onStage.id)?.tour_stage_key).toBe('hut-1');
|
||||
expect(rows.find((row) => row.assignment_id === onDay.id)?.tour_stage_key).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user