fix: Slots are available even after exceeding the booking limits for the team event (#21801)

* fix: slots available

* fix type error

* update

* update
This commit is contained in:
Anik Dhabal Babu
2025-06-19 20:05:43 +05:30
committed by GitHub
parent e160a4add0
commit 601df7f808
2 changed files with 14 additions and 14 deletions
@@ -58,6 +58,17 @@ export default class LimitManager {
});
}
/**
* Merges busy times from another LimitManager
*/
mergeBusyTimes(otherManager: LimitManager) {
otherManager.busyMap.forEach((busyTime, key) => {
if (!this.busyMap.has(key)) {
this.busyMap.set(key, busyTime);
}
});
}
/**
* Returns all busy times
*/
@@ -30,7 +30,7 @@ import { parseBookingLimit } from "@calcom/lib/intervalLimits/isBookingLimits";
import { parseDurationLimit } from "@calcom/lib/intervalLimits/isDurationLimits";
import LimitManager from "@calcom/lib/intervalLimits/limitManager";
import { checkBookingLimit } from "@calcom/lib/intervalLimits/server/checkBookingLimits";
import { getUnitFromBusyTime, isBookingWithinPeriod } from "@calcom/lib/intervalLimits/utils";
import { isBookingWithinPeriod } from "@calcom/lib/intervalLimits/utils";
import {
calculatePeriodLimits,
isTimeOutOfBounds,
@@ -1031,13 +1031,7 @@ const _getBusyTimesFromLimitsForUsers = async (
const userBookings = busyTimesFromLimitsBookings.filter((booking) => booking.userId === user.id);
const limitManager = new LimitManager();
for (const busyTime of globalLimitManager.getBusyTimes()) {
const start = dayjs(busyTime.start);
const end = dayjs(busyTime.end);
const unit = getUnitFromBusyTime(start, end);
limitManager.addBusyTime(start, unit, timeZone);
}
limitManager.mergeBusyTimes(globalLimitManager);
if (bookingLimits) {
for (const key of descendingLimitKeys) {
@@ -1222,13 +1216,8 @@ const _getBusyTimesFromTeamLimitsForUsers = async (
const userBusyTimes = busyTimes.filter((busyTime) => busyTime.userId === user.id);
const limitManager = new LimitManager();
for (const busyTime of globalLimitManager.getBusyTimes()) {
const start = dayjs(busyTime.start);
const end = dayjs(busyTime.end);
const unit = getUnitFromBusyTime(start, end);
limitManager.mergeBusyTimes(globalLimitManager);
limitManager.addBusyTime(start, unit, timeZone);
}
const bookingLimitsParams = {
bookings: userBusyTimes,
bookingLimits,