mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
fix(reservations): a booking read on its own carries its day slots, so an edit no longer drops them
The create and update answers, the reservation:updated broadcast and the MCP reservation tools all hand back the single booking read, and that read never loaded reservation_day_positions. The day list puts a booking moved on a day by that slot before its time, and the client replaces the booking with the answer, so a booking moved on a day jumped back to its time after every edit until the next reload. The read now attaches day_positions in the shape the trip list already sends. Refs #2631
This commit is contained in:
@@ -32,6 +32,20 @@ export class ReservationDayPositionsRepository extends TrekRepository<Reservatio
|
||||
.execute<{ reservation_id: number; day_id: number; position: number }[]>('all', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* `SELECT day_id, position FROM reservation_day_positions WHERE reservation_id = ?`:
|
||||
* one booking's slots, for the single-booking read the create, update and
|
||||
* broadcast payloads come from. Without them a booking moved on a day lost
|
||||
* that slot in the list after every edit until the next reload (#2631).
|
||||
*/
|
||||
async listForReservation(reservation_id: number): Promise<{ day_id: number; position: number }[]> {
|
||||
return this.kysely<ReservationDayPositionsKyselyDB>()
|
||||
.selectFrom('reservation_day_positions')
|
||||
.select(['day_id', 'position'])
|
||||
.where('reservation_id', '=', reservation_id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* RS31 (`ReservationsService.updatePositions`'s day branch) — `INSERT OR
|
||||
* REPLACE INTO reservation_day_positions (reservation_id, day_id,
|
||||
|
||||
Reference in New Issue
Block a user