Booking Limits checking ALL events not the event the limit is applied too (#5601)
* Fix error message * Only apply buffer limits to That event type * Correctly get eventtypeId in source * Add comment * Move to i188n strings * Wrap string to be translated Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
1 parent
994df45a19
commit
9441a79def
5 files changed
+11
-6
No files matched your search
@@ -52,6 +52,7 @@ export async function getBusyTimes(params: {
|
||||
title: true,
|
||||
eventType: {
|
||||
select: {
|
||||
id: true,
|
||||
afterEventBuffer: true,
|
||||
beforeEventBuffer: true,
|
||||
},
|
||||
@@ -67,7 +68,7 @@ export async function getBusyTimes(params: {
|
||||
.add((eventType?.afterEventBuffer || 0) + (beforeEventBuffer || 0), "minute")
|
||||
.toDate(),
|
||||
title,
|
||||
source: `eventType-${eventTypeId}-booking-${id}`,
|
||||
source: `eventType-${eventType?.id}-booking-${id}`,
|
||||
}))
|
||||
);
|
||||
logger.silly(`Busy Time from Cal Bookings ${JSON.stringify(busyTimes)}`);
|
||||
|
||||
@@ -202,10 +202,13 @@ export async function getUserAvailability(
|
||||
const startDate = dayjs(booking.start).startOf(filter);
|
||||
// this is parsed above with parseBookingLimit so we know it's safe.
|
||||
const endDate = dayjs(startDate).endOf(filter);
|
||||
|
||||
const bookingEventTypeId = booking.source?.split("-")[1];
|
||||
if (dayjs(booking.start).isBetween(startDate, endDate)) total++;
|
||||
if (total >= limit)
|
||||
// Only check OUR booking that matches the current eventTypeId
|
||||
// we don't care about another event type in this case as we dont need to know their booking limits
|
||||
if (total >= limit && bookingEventTypeId === eventType?.id?.toString()) {
|
||||
bufferedBusyTimes.push({ start: startDate.toISOString(), end: endDate.toISOString() });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user