Skip to content

Commit

Permalink
Fix unconfirmed bookings blocking slots being fetched for all trouble…
Browse files Browse the repository at this point in the history
…shooters
  • Loading branch information
hariombalhara committed Aug 31, 2024
1 parent b6bcc43 commit a573944
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/core/getBusyTimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,31 @@ export async function getBusyTimes(params: {
select: bookingsSelect,
});

const currentBookingsAllUsersQueryThree = prisma.booking.findMany({
where: {
startTime: { lte: endTimeDate },
endTime: { gte: startTimeDate },
eventType: {
id: eventTypeId,
requiresConfirmation: true,
requiresConfirmationWillBlockSlot: true,
},
status: {
in: [BookingStatus.PENDING],
},
},
select: bookingsSelect,
});
const currentBookingsAllUsersQueryThree = eventTypeId
? prisma.booking.findMany({
where: {
startTime: { lte: endTimeDate },
endTime: { gte: startTimeDate },
eventType: {
id: eventTypeId,
requiresConfirmation: true,
requiresConfirmationWillBlockSlot: true,
},
status: {
in: [BookingStatus.PENDING],
},
},
select: bookingsSelect,
})
: null;

const [resultOne, resultTwo, resultThree] = await Promise.all([
currentBookingsAllUsersQueryOne,
currentBookingsAllUsersQueryTwo,
currentBookingsAllUsersQueryThree,
]);

bookings = [...resultOne, ...resultTwo, ...resultThree];
bookings = [...resultOne, ...resultTwo, ...(resultThree ?? [])];
}

const bookingSeatCountMap: { [x: string]: number } = {};
Expand Down

0 comments on commit a573944

Please sign in to comment.