perf: Add more specific spans to getBusyTimes (#17437)
* perf: Add more specific spans to getBusyTimes * fix types
This commit is contained in:
1 parent
bcc1a8e279
commit
6c5b12db57
1 file changed
+11
@@ -1,5 +1,6 @@
|
||||
import type { Booking, EventType } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
import { getBusyCalendarTimes } from "@calcom/core/CalendarManager";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
@@ -110,6 +111,7 @@ export async function getBusyTimes(params: {
|
||||
let bookings = params.currentBookings;
|
||||
|
||||
if (!bookings) {
|
||||
const getBookingsForBusyTimesSpan = Sentry.startInactiveSpan({ name: "getBookingsForBusyTimes" });
|
||||
const bookingsSelect = Prisma.validator<Prisma.BookingSelect>()({
|
||||
id: true,
|
||||
uid: true,
|
||||
@@ -180,6 +182,8 @@ export async function getBusyTimes(params: {
|
||||
]);
|
||||
|
||||
bookings = [...resultOne, ...resultTwo, ...(resultThree ?? [])];
|
||||
|
||||
getBookingsForBusyTimesSpan.end();
|
||||
}
|
||||
|
||||
const bookingSeatCountMap: { [x: string]: number } = {};
|
||||
@@ -249,6 +253,8 @@ export async function getBusyTimes(params: {
|
||||
})
|
||||
);
|
||||
|
||||
const openSeatsDateRangesSpan = Sentry.startInactiveSpan({ name: "openSeatsDateRanges" });
|
||||
|
||||
const openSeatsDateRanges = Object.keys(bookingSeatCountMap).map((key) => {
|
||||
const [start, end] = key.split("<>");
|
||||
return {
|
||||
@@ -257,6 +263,8 @@ export async function getBusyTimes(params: {
|
||||
};
|
||||
});
|
||||
|
||||
openSeatsDateRangesSpan.end();
|
||||
|
||||
if (rescheduleUid) {
|
||||
const originalRescheduleBooking = bookings.find((booking) => booking.uid === rescheduleUid);
|
||||
// calendar busy time from original rescheduled booking should not be blocked
|
||||
@@ -268,6 +276,7 @@ export async function getBusyTimes(params: {
|
||||
}
|
||||
}
|
||||
|
||||
const finalizeBusyTimesSpan = Sentry.startInactiveSpan({ name: "finalizeBusyTimes" });
|
||||
const result = subtract(
|
||||
calendarBusyTimes.map((value) => ({
|
||||
...value,
|
||||
@@ -285,6 +294,8 @@ export async function getBusyTimes(params: {
|
||||
}))
|
||||
);
|
||||
|
||||
finalizeBusyTimesSpan.end();
|
||||
|
||||
/*
|
||||
// TODO: Disabled until we can filter Zoom events by date. Also this is adding too much latency.
|
||||
const videoBusyTimes = (await getBusyVideoTimes(credentials)).filter(notEmpty);
|
||||
|
||||
Reference in new issue
Block a user