From 1d5b383529a6073b7c8e4cf2cb6372c7f59e3228 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Thu, 27 Jul 2023 17:33:24 +0100 Subject: [PATCH] fix: weekly limits (#10404) * fix: correctly apply duration limits * fix: weekly limits for weeks in two months --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> --- packages/core/getUserAvailability.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/getUserAvailability.ts b/packages/core/getUserAvailability.ts index 044e3478b0..49fbb71944 100644 --- a/packages/core/getUserAvailability.ts +++ b/packages/core/getUserAvailability.ts @@ -42,6 +42,7 @@ const getEventType = async (id: number) => { bookingLimits: true, durationLimits: true, timeZone: true, + length: true, metadata: true, schedule: { select: { @@ -165,8 +166,9 @@ export async function getUserAvailability( const busyTimes = await getBusyTimes({ credentials: user.credentials, - startTime: dateFrom.toISOString(), - endTime: dateTo.toISOString(), + // needed to correctly apply limits (weeks can be part of two months) + startTime: dateFrom.startOf("week").toISOString(), + endTime: dateTo.endOf("week").toISOString(), eventTypeId, userId: user.id, username: `${user.username}`, @@ -374,7 +376,7 @@ const getBusyTimesFromDurationLimits = async ( // loop through all dates and check if we have reached the limit for (const date of dates) { - let total = duration ?? 0; + let total = (duration || eventType?.length) ?? 0; const startDate = date.startOf(filter); const endDate = date.endOf(filter);