Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unconfirmed booking busytimes of other users being fetched in troubleshooter #16439

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

@hariombalhara hariombalhara Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If id is undefined, it can target all event-types. eventTypeId is optional in the function and it isn't provided in case of troubleshooter

Something similar to #15721 could help in this case as well.

Also, this could potentially be a reason for the recent slowness in DB as it is querying all eventTypes in DB(AFAIU)

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
Loading