mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 00:20:07 +00:00
feat(tours): plan a multi-day tour as one route split into stages
A hut-to-hut hike or a paddle trip over several days is now planned in the Tours planner as one tour: the whole route is planned as before, and stops along it are marked as stage ends (MDT-01). The stages are read off that one route in its order, never kept as copies, so a change inside a stage changes the whole tour and every figure on it. - A Day tour / Multi-day tour switch beside the tour type; a stop's menu ends a stage there or lets it go on. Back to a day tour removes every stage end after a confirmation, as one step undo brings back. - The list of points is headed per stage with its distance and moving time; a stop that ends a stage carries a moon at its number, on the map too. - The overview lists the stages from stop to stop with distance, climb, descent and time (hiking rule per stage, paddle estimate per stage, the router's time shared by distance otherwise), marks where each ends across the elevation profile, and a stage of more than a day on the move warns. - A stage end a change cannot keep (its stop removed, moved to an end or made a shaping point) is dropped and said so, with undo, never moved to another point. - A multi-day tour may take a day a stage, so its time limit grows with its stages; the tour keeps its one type, portages included. - The list and the MCP tools show the stage count and where stages end. Stage ends are a flag on the waypoint (migration 046000); a tour without one is a day tour, as every tour saved before.
This commit is contained in:
@@ -74,6 +74,7 @@ const UNNUMBERED = [
|
||||
'Migration20200101045710_a_saved_tour_change_can_be_taken_back',
|
||||
'Migration20200101045900_a_tour_keeps_the_track_it_was_done_with',
|
||||
'Migration20200101045910_a_tour_can_be_left_out_of_ones_activities',
|
||||
'Migration20200101046000_a_tour_waypoint_can_end_a_stage',
|
||||
];
|
||||
// The last step the positional runner ever had; planLegacyBaseline refuses a
|
||||
// schema_version past it.
|
||||
|
||||
@@ -221,6 +221,21 @@ describe('TourWaypointsRepository', () => {
|
||||
expect((await repo.listForPlace(place.id))[1]).not.toHaveProperty('poi_category');
|
||||
});
|
||||
|
||||
it('TWREPO-012: a stop that ends a stage is stored as such and read back; the others carry no flag (MDT-01)', async () => {
|
||||
const { trip, place } = tourInTrip();
|
||||
await repo.insertForPlace(place.id, [
|
||||
{ lat: 47, lng: 11, role: 'start', sequence: 0 },
|
||||
{ lat: 47.05, lng: 11.05, role: 'via', sequence: 1, stage_end: true },
|
||||
{ lat: 47.1, lng: 11.1, role: 'end', sequence: 2 },
|
||||
]);
|
||||
const points = await repo.listForPlace(place.id);
|
||||
expect(points[1]).toEqual({ lat: 47.05, lng: 11.05, role: 'via', sequence: 1, stage_end: true });
|
||||
expect(points[0]).not.toHaveProperty('stage_end');
|
||||
expect(points[2]).not.toHaveProperty('stage_end');
|
||||
// A trip copy reads the mark with the rest of the point.
|
||||
expect((await repo.listForTrip(trip.id))[1]).toMatchObject({ place_id: place.id, stage_end: true });
|
||||
});
|
||||
|
||||
it('TWREPO-010: listForPlaces reads the waypoints of the tours asked for, by place and sequence, and none for none (CW-02)', async () => {
|
||||
const { trip, place } = tourInTrip();
|
||||
const second = await makePlace(t, trip.id);
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { ToursRepository } from '../../../../src/db/repositories/Tours.repo
|
||||
import { createSnapshotTestDb } from '../../../helpers/db-mock';
|
||||
import { createDay, createDayAssignment, createPlace, createTrip, createUser } from '../../../helpers/factories';
|
||||
import { makePlace } from '../../../helpers/factories/places';
|
||||
import { insertRow, updateRows } from '../../../helpers/factories/rows';
|
||||
import { insertRow, insertRows, updateRows } from '../../../helpers/factories/rows';
|
||||
import { makeDay } from '../../../helpers/factories/trips';
|
||||
import { resetTestDb } from '../../../helpers/test-db';
|
||||
import { createTestOrm, type TestOrm } from '../../../helpers/test-orm';
|
||||
@@ -112,6 +112,7 @@ describe('ToursRepository reads', () => {
|
||||
ski_technique: null,
|
||||
track_started_at: null,
|
||||
track_ended_at: null,
|
||||
stage_ends: 0,
|
||||
},
|
||||
{
|
||||
place_id: older.id,
|
||||
@@ -151,6 +152,7 @@ describe('ToursRepository reads', () => {
|
||||
ski_technique: null,
|
||||
track_started_at: null,
|
||||
track_ended_at: null,
|
||||
stage_ends: 0,
|
||||
},
|
||||
]);
|
||||
expect((await repo.listForTrip(trip.id)).map((r) => r.place_id)).not.toContain(plain.id);
|
||||
@@ -195,6 +197,32 @@ describe('ToursRepository reads', () => {
|
||||
expect((await repo.findInTrip(trip.id, drawn.id))?.route_missing).toBe(0);
|
||||
});
|
||||
|
||||
it('TOURREPO-016: the list and the detail count the stops that end a stage, 0 for a day tour (MDT-01)', async () => {
|
||||
const { trip } = fixture();
|
||||
const hutToHut = await makePlace(t, trip.id, { name: 'Hut to hut' });
|
||||
const dayHike = await makePlace(t, trip.id, { name: 'Day hike' });
|
||||
createTour(testDb, hutToHut.id);
|
||||
createTour(testDb, dayHike.id);
|
||||
await insertRows(
|
||||
t,
|
||||
TourWaypoints,
|
||||
[0, 1, 1, 0].map((stage_end, sequence) => ({
|
||||
place: hutToHut.id,
|
||||
lat: 47,
|
||||
lng: 11,
|
||||
role: 'via',
|
||||
sequence,
|
||||
stage_end,
|
||||
})),
|
||||
);
|
||||
await addWaypoint(dayHike.id, 0);
|
||||
|
||||
const listed = new Map((await repo.listForTrip(trip.id)).map((row) => [row.place_id, row.stage_ends]));
|
||||
expect(listed.get(hutToHut.id)).toBe(2);
|
||||
expect(listed.get(dayHike.id)).toBe(0);
|
||||
expect((await repo.findInTrip(trip.id, hutToHut.id))?.stage_ends).toBe(2);
|
||||
});
|
||||
|
||||
it('TOURREPO-015: dayOfTrip reads a day of the trip with its date, and nothing for a day of another trip', async () => {
|
||||
const { trip, other } = fixture();
|
||||
const dated = await makeDay(t, trip.id, { date: '2026-07-12' });
|
||||
|
||||
Reference in New Issue
Block a user