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 4f63ba1
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 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 unconfirmedBookingsBlockingSlots = 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,
unconfirmedBookingsBlockingSlots,
]);

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

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

0 comments on commit 4f63ba1

Please sign in to comment.