perf: Prevent parse when object is empty, resulting in a truthy value (#22625)
This commit is contained in:
1 parent
0aa595ddac
commit
e901e8d189
2 files changed
+27
-7
No files matched your search
@@ -345,8 +345,19 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
|
||||
fallbackSchedule;
|
||||
const timeZone = schedule?.timeZone || fallbackTimezoneIfScheduleIsMissing;
|
||||
|
||||
const bookingLimits = parseBookingLimit(eventType?.bookingLimits);
|
||||
const durationLimits = parseDurationLimit(eventType?.durationLimits);
|
||||
const bookingLimits =
|
||||
eventType?.bookingLimits &&
|
||||
typeof eventType.bookingLimits === "object" &&
|
||||
Object.keys(eventType.bookingLimits).length > 0
|
||||
? parseBookingLimit(eventType.bookingLimits)
|
||||
: null;
|
||||
|
||||
const durationLimits =
|
||||
eventType?.durationLimits &&
|
||||
typeof eventType.durationLimits === "object" &&
|
||||
Object.keys(eventType.durationLimits).length > 0
|
||||
? parseDurationLimit(eventType.durationLimits)
|
||||
: null;
|
||||
|
||||
let busyTimesFromLimits: EventBusyDetails[] = [];
|
||||
|
||||
|
||||
@@ -732,8 +732,20 @@ export class AvailableSlotsService {
|
||||
this.getOOODates(startTimeDate, endTimeDate, allUserIds),
|
||||
]);
|
||||
|
||||
const bookingLimits = parseBookingLimit(eventType?.bookingLimits);
|
||||
const durationLimits = parseDurationLimit(eventType?.durationLimits);
|
||||
const bookingLimits =
|
||||
eventType?.bookingLimits &&
|
||||
typeof eventType?.bookingLimits === "object" &&
|
||||
Object.keys(eventType?.bookingLimits).length > 0
|
||||
? parseBookingLimit(eventType?.bookingLimits)
|
||||
: null;
|
||||
|
||||
const durationLimits =
|
||||
eventType?.durationLimits &&
|
||||
typeof eventType?.durationLimits === "object" &&
|
||||
Object.keys(eventType?.durationLimits).length > 0
|
||||
? parseDurationLimit(eventType?.durationLimits)
|
||||
: null;
|
||||
|
||||
let busyTimesFromLimitsBookingsAllUsers: Awaited<ReturnType<typeof getBusyTimesForLimitChecks>> = [];
|
||||
|
||||
if (eventType && (bookingLimits || durationLimits)) {
|
||||
@@ -1270,11 +1282,8 @@ export class AvailableSlotsService {
|
||||
const mapSlotsToDate = withReporting(_mapSlotsToDate.bind(this), "mapSlotsToDate");
|
||||
const slotsMappedToDate = mapSlotsToDate();
|
||||
|
||||
loggerWithEventDetails.debug({ slotsMappedToDate });
|
||||
|
||||
const availableDates = Object.keys(slotsMappedToDate);
|
||||
const allDatesWithBookabilityStatus = this.getAllDatesWithBookabilityStatus(availableDates);
|
||||
loggerWithEventDetails.debug({ availableDates });
|
||||
|
||||
// timeZone isn't directly set on eventType now(So, it is legacy)
|
||||
// schedule is always expected to be set for an eventType now so it must never fallback to allUsersAvailability[0].timeZone(fallback is again legacy behavior)
|
||||
|
||||
Reference in new issue
Block a user