mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 07:38:10 +00:00
Fix blocked seat count on booking result
This commit is contained in:
@@ -390,8 +390,8 @@ export class SearchService {
|
||||
// Exclude schedules with no seats at all
|
||||
if (allValidSeatIds.length === 0) return null;
|
||||
|
||||
// Run availability batch and fare calculation in parallel
|
||||
const [freeSeats, faresByClass] = await Promise.all([
|
||||
// Run availability batch, fare calculation, and schedule-scoped seat blocks in parallel
|
||||
const [freeSeatsRaw, faresByClass, scheduleBlocks] = await Promise.all([
|
||||
this.segmentsService.getFreeSeatIds(
|
||||
schedule.id,
|
||||
allValidSeatIds,
|
||||
@@ -400,7 +400,17 @@ export class SearchService {
|
||||
destStop.sequence,
|
||||
),
|
||||
this.calculateFaresForSegment(schedule, originStationId, destinationStationId, nationality),
|
||||
this.prisma.seatBlock.findMany({
|
||||
where: {
|
||||
scheduleId: schedule.id,
|
||||
seatId: { in: allValidSeatIds },
|
||||
},
|
||||
select: { seatId: true },
|
||||
}),
|
||||
]);
|
||||
const scheduleBlockedIds = new Set(scheduleBlocks.map((b: any) => b.seatId));
|
||||
// Seats that are free from holds/bookings AND not schedule-blocked
|
||||
const freeSeats = new Set([...freeSeatsRaw].filter(id => !scheduleBlockedIds.has(id)));
|
||||
|
||||
// Compute per-class availability using the pre-computed free seat set. A coach type
|
||||
// has separate seat classes per nationality tier (e.g. "VIP Bed Upper (Local)" AND
|
||||
|
||||
Reference in New Issue
Block a user