mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix(calendar): a timed stop without an end time ends after the place duration
A stop with a start time but no end time went out as a VEVENT without DTEND. Calendar clients fill in their own default length for that, mostly an hour, so a 20 minute stop showed up as an hour. The event now ends at start plus the place's duration_minutes when that is set and above zero, carried over midnight like the stay markers. An explicit end time still wins, so start and end under an hour stay as they were. The trip download, both calendar feeds and the MCP export share this builder. Refs #2641
This commit is contained in:
@@ -174,9 +174,10 @@ type CalendarReservationKyselyDB = Pick<DB, 'reservations' | 'places' | 'day_acc
|
||||
/**
|
||||
* CL4 (`CalendarService.buildTripCalendar`'s assignment read, for every dated
|
||||
* day at once) — `SELECT da.*, p.name as place_name, p.address as
|
||||
* place_address, p.lat as place_lat, p.lng as place_lng,
|
||||
* COALESCE(da.assignment_time, p.place_time) as effective_time,
|
||||
* COALESCE(da.assignment_end_time, p.end_time) as effective_end_time FROM
|
||||
* place_address, p.lat as place_lat, p.lng as place_lng, p.duration_minutes
|
||||
* as place_duration_minutes, COALESCE(da.assignment_time, p.place_time) as
|
||||
* effective_time, COALESCE(da.assignment_end_time, p.end_time) as
|
||||
* effective_end_time FROM
|
||||
* day_assignments da JOIN places p ON da.place_id = p.id WHERE da.day_id IN
|
||||
* (...) AND da.accommodation_id IS NULL ORDER BY da.order_index, da.created_at,
|
||||
* da.id` — the booked-night stop (its own accommodation-linked row) is
|
||||
@@ -188,6 +189,7 @@ export interface CalendarStopRow extends DayAssignmentRow {
|
||||
place_address: string | null;
|
||||
place_lat: number | null;
|
||||
place_lng: number | null;
|
||||
place_duration_minutes: number | null;
|
||||
effective_time: string | null;
|
||||
effective_end_time: string | null;
|
||||
}
|
||||
@@ -1004,6 +1006,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {
|
||||
'p.address as place_address',
|
||||
'p.lat as place_lat',
|
||||
'p.lng as place_lng',
|
||||
'p.duration_minutes as place_duration_minutes',
|
||||
eb.fn.coalesce('da.assignment_time', 'p.place_time').as('effective_time'),
|
||||
eb.fn.coalesce('da.assignment_end_time', 'p.end_time').as('effective_end_time'),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user