Fixes the slow performance due to the Dayjs timezone plugin (#3201)

* Fixes the slow performance due to the Dayjs timezone plugin

* Bye.

* Parses busyTime in UTC
pull/3195/head^2
Alex van Andel 2022-06-30 01:33:19 +01:00 committed by GitHub
parent a91f251b98
commit 53bbbf793d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,6 @@ import { z } from "zod";
import type { CurrentSeats } from "@calcom/core/getUserAvailability"; import type { CurrentSeats } from "@calcom/core/getUserAvailability";
import { getUserAvailability } from "@calcom/core/getUserAvailability"; import { getUserAvailability } from "@calcom/core/getUserAvailability";
import dayjs, { Dayjs } from "@calcom/dayjs"; import dayjs, { Dayjs } from "@calcom/dayjs";
import { yyyymmdd } from "@calcom/lib/date-fns";
import { availabilityUserSelect } from "@calcom/prisma"; import { availabilityUserSelect } from "@calcom/prisma";
import { stringToDayjs } from "@calcom/prisma/zod-utils"; import { stringToDayjs } from "@calcom/prisma/zod-utils";
import { TimeRange } from "@calcom/types/schedule"; import { TimeRange } from "@calcom/types/schedule";
@ -59,15 +58,16 @@ const checkForAvailability = ({
return true; return true;
} }
const slotEndTime = time.add(eventLength, "minutes"); const slotEndTime = time.add(eventLength, "minutes").utc();
const slotStartTimeWithBeforeBuffer = time.subtract(beforeBufferTime, "minutes"); const slotStartTimeWithBeforeBuffer = time.subtract(beforeBufferTime, "minutes").utc();
const slotEndTimeWithAfterBuffer = time.add(eventLength + afterBufferTime, "minutes"); const slotEndTimeWithAfterBuffer = time.add(eventLength + afterBufferTime, "minutes").utc();
return busy.every((busyTime) => {
const startTime = dayjs.utc(busyTime.start);
const endTime = dayjs.utc(busyTime.end);
return busy.every((busyTime): boolean => {
const startTime = dayjs(busyTime.start);
const endTime = dayjs(busyTime.end);
// Check if start times are the same // Check if start times are the same
if (time.isBetween(startTime, endTime, null, "[)")) { if (time.utc().isBetween(startTime, endTime, null, "[)")) {
return false; return false;
} }
// Check if slot end time is between start and end time // Check if slot end time is between start and end time