mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
fix(roadtrip): a booked ferry is driven to, and one without a date says so
A ferry between two stops without a clock was seated by the clock alone, which files a ride with nothing timed before it at the end of the day. The desktop day list stored that slot, and the road trip drove overland to the far shore and back to the pier before the crossing. A ride that leaves and lands on the same day, with both terminals located, now takes the seat between the clocks that adds the fewest straight-line kilometres. One rule in shared seats it for the day list, the slot the desktop stores, the phone and PDF lists and the road trip in the browser and on the server. Slots already stored are left alone. A flight, train, ferry, cruise or bus on no day made no seam and said nothing, while the map still drew its arc. The rail and the phone tab now name such a booking with a way to open it, and calculate_roadtrip lists it under undatedRides.
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
formatDistance,
|
||||
formatDurationShort,
|
||||
seatCarrierStops,
|
||||
undatedRides,
|
||||
viasLeaving,
|
||||
type CarrierBooking,
|
||||
type CarrierSeam,
|
||||
@@ -128,11 +129,35 @@ export class RoadtripPlanService {
|
||||
* reservations graph.
|
||||
*/
|
||||
private carriers(tripId: number): CarrierBooking[] {
|
||||
return this.withTerminals(
|
||||
tripId,
|
||||
this.db.all<CarrierRow>(
|
||||
`SELECT id, type, title, day_id, end_day_id, reservation_time, reservation_end_time, metadata, day_plan_position
|
||||
FROM reservations WHERE trip_id = ? AND type IN ('flight', 'train', 'ferry', 'cruise', 'bus', 'car') AND day_id IS NOT NULL`,
|
||||
tripId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The rides the drive leaves out because they are on no day: a flight, train, ferry,
|
||||
* cruise or bus with both terminals located and no day to leave on (#2461). The map
|
||||
* draws their arcs all the same, so the answer names them rather than leaving an
|
||||
* assistant to read a drive around a booked crossing as the plan. Which ones count is
|
||||
* `undatedRides` alone, the rule the planner's rail lists them by, so the statement
|
||||
* names no types of its own.
|
||||
*/
|
||||
undatedRides(tripId: number): { id: number; type: string; title: string }[] {
|
||||
const rows = this.db.all<CarrierRow>(
|
||||
`SELECT id, type, title, day_id, end_day_id, reservation_time, reservation_end_time, metadata, day_plan_position
|
||||
FROM reservations WHERE trip_id = ? AND type IN ('flight', 'train', 'ferry', 'cruise', 'bus', 'car') AND day_id IS NOT NULL`,
|
||||
FROM reservations WHERE trip_id = ? AND day_id IS NULL`,
|
||||
tripId,
|
||||
);
|
||||
return undatedRides(this.withTerminals(tripId, rows)).map(({ id, type, title }) => ({ id, type, title }));
|
||||
}
|
||||
|
||||
/** The rows with their terminals and the slots the day plan gave them joined on. */
|
||||
private withTerminals(tripId: number, rows: CarrierRow[]): CarrierBooking[] {
|
||||
if (!rows.length) return [];
|
||||
const endpoints = this.db.all<{
|
||||
reservation_id: number;
|
||||
@@ -359,6 +384,7 @@ export class RoadtripPlanService {
|
||||
calculated,
|
||||
failures,
|
||||
omittedVisits: context.visits.filter((v) => v.lat === null || v.lng === null).map((v) => v.id),
|
||||
undatedRides: this.undatedRides(tripId),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class RoadtripPlanningMcp {
|
||||
@Tool({
|
||||
name: 'calculate_roadtrip',
|
||||
description:
|
||||
'Calculate a saved trip without an open browser, using the same daily scheduling and vehicle-range rules as the planner. Returns derived days, arrivals, departures, driving limits, fuel warnings, automatic pauses and routing failures. A flight, train, ferry, cruise or bus booking with located terminals is a seam: its terminals appear as stops carrying `carrier` (role departure or arrival), the road ends at the departure terminal and resumes at the arrival one, and the leg between them is the ride, in the mode of the booking type, with its timetable minutes and no distance. A hire car booking with a located pick-up desk puts that desk on the road as a stop carrying `carrier` with role pickup, and its return desk with role return when the booking names a return day and place; the road runs through both. Fixed visit times retain priority. The end time of a visit is when the drive leaves it, in place of its stay; reaching the visit after it is reported as a missedLeave warning. No accommodation or place is created. Optional settings are a read-only preview, not saved. Distances are metres, durations seconds, dwell times minutes. A failed leg or conflicting window means the output is incomplete: never present its totals as a complete route. Up to 150 legs; requests are paced for public routing servers and can take time. Existing place/assignment tools edit stops, stays and ordering, update_roadtrip_settings saves preferences, set_assignment_end_day and set_day_boundary set exceptions. Recalculate after changes. Plugin profiles follow installed route-provider permissions.',
|
||||
'Calculate a saved trip without an open browser, using the same daily scheduling and vehicle-range rules as the planner. Returns derived days, arrivals, departures, driving limits, fuel warnings, automatic pauses and routing failures. A flight, train, ferry, cruise or bus booking with located terminals is a seam: its terminals appear as stops carrying `carrier` (role departure or arrival), the road ends at the departure terminal and resumes at the arrival one, and the leg between them is the ride, in the mode of the booking type, with its timetable minutes and no distance. A hire car booking with a located pick-up desk puts that desk on the road as a stop carrying `carrier` with role pickup, and its return desk with role return when the booking names a return day and place; the road runs through both. A flight, train, ferry, cruise or bus booking on no day is not on the drive at all, although its terminals are located: undatedRides lists each one (id, type, title) so it can be given a date with the reservation tools, after which the road ends at its terminal. Fixed visit times retain priority. The end time of a visit is when the drive leaves it, in place of its stay; reaching the visit after it is reported as a missedLeave warning. No accommodation or place is created. Optional settings are a read-only preview, not saved. Distances are metres, durations seconds, dwell times minutes. A failed leg or conflicting window means the output is incomplete: never present its totals as a complete route. Up to 150 legs; requests are paced for public routing servers and can take time. Existing place/assignment tools edit stops, stays and ordering, update_roadtrip_settings saves preferences, set_assignment_end_day and set_day_boundary set exceptions. Recalculate after changes. Plugin profiles follow installed route-provider permissions.',
|
||||
inputSchema: roadtripPlanRequestSchema.shape,
|
||||
annotations: TOOL_ANNOTATIONS_READONLY,
|
||||
access: { group: 'trips', mode: 'read' },
|
||||
@@ -64,6 +64,7 @@ export class RoadtripPlanningMcp {
|
||||
settings: plan.preferences,
|
||||
failures: plan.failures,
|
||||
omittedVisitIds: plan.omittedVisits,
|
||||
undatedRides: plan.undatedRides,
|
||||
dayWindowIssue: calculated.dayWindowIssue,
|
||||
totalDistanceMetres: calculated.totalDistance,
|
||||
totalDurationSeconds: calculated.totalDuration,
|
||||
|
||||
Reference in New Issue
Block a user