mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 04:08:11 +00:00
changes
This commit is contained in:
@@ -1286,6 +1286,31 @@ export class BookingBatchService implements OnModuleInit {
|
|||||||
(s.scheduleBookings ?? []).map((l) => l.bookingId),
|
(s.scheduleBookings ?? []).map((l) => l.bookingId),
|
||||||
);
|
);
|
||||||
const bookings = await this.bookingsRepository.findAllBySchedule(s.id);
|
const bookings = await this.bookingsRepository.findAllBySchedule(s.id);
|
||||||
|
// Under day-level pooling a booking is only pinned to a schedule by
|
||||||
|
// reserve() — until then its train_schedule_id is NULL and the query above
|
||||||
|
// misses it. Merge in the corridor-day candidates so staff see the whole
|
||||||
|
// waiting pool (the 7 that lost the batch), not just the winners. These are
|
||||||
|
// display-only candidates: they are excluded from the capacity meters below.
|
||||||
|
const pinnedIds = new Set(bookings.map((b) => b.id));
|
||||||
|
if (s.scheduledDepartureDate) {
|
||||||
|
try {
|
||||||
|
const stops = await this.stopsForSchedule(s);
|
||||||
|
const candidates =
|
||||||
|
await this.bookingsRepository.findBatchPoolByCorridorDay(
|
||||||
|
stops,
|
||||||
|
eatDay(s.scheduledDepartureDate),
|
||||||
|
);
|
||||||
|
for (const b of candidates) {
|
||||||
|
if (!pinnedIds.has(b.id)) bookings.push(b);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// The board must still render the pinned bookings.
|
||||||
|
this.logger.warn(
|
||||||
|
`Corridor-day candidate merge failed for schedule ${s.id}: ` +
|
||||||
|
`${(err as Error).message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let allocationPreview: Awaited<
|
let allocationPreview: Awaited<
|
||||||
ReturnType<TrainSchedulingService["previewAllocationForSchedule"]>
|
ReturnType<TrainSchedulingService["previewAllocationForSchedule"]>
|
||||||
@@ -1437,7 +1462,13 @@ export class BookingBatchService implements OnModuleInit {
|
|||||||
maxTrainLengthMeters: Number(loco.maxTrainLengthMeters),
|
maxTrainLengthMeters: Number(loco.maxTrainLengthMeters),
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
capacity: this.computeBoardCapacity(items, loco, s.maxWagons ?? null),
|
// Capacity holds come from bookings actually pinned to this train —
|
||||||
|
// unpinned day-pool candidates are shown in the lists but hold nothing.
|
||||||
|
capacity: this.computeBoardCapacity(
|
||||||
|
items.filter((i) => pinnedIds.has(i.id)),
|
||||||
|
loco,
|
||||||
|
s.maxWagons ?? null,
|
||||||
|
),
|
||||||
counts: {
|
counts: {
|
||||||
allocated: items.filter((i) => i.state === "ALLOCATED").length,
|
allocated: items.filter((i) => i.state === "ALLOCATED").length,
|
||||||
selectedForBatch: items.filter((i) => i.state === "SELECTED_FOR_BATCH")
|
selectedForBatch: items.filter((i) => i.state === "SELECTED_FOR_BATCH")
|
||||||
|
|||||||
Reference in New Issue
Block a user