Add logging (#21874)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { ErrorWithCode } from "@calcom/lib/errors";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
const log = logger.getSubLogger({ prefix: ["[checkActiveBookingsLimitForBooker]"] });
|
||||
|
||||
export const checkActiveBookingsLimitForBooker = async ({
|
||||
eventTypeId,
|
||||
maxActiveBookingsPerBooker,
|
||||
@@ -57,6 +60,7 @@ const checkActiveBookingsLimit = async ({
|
||||
});
|
||||
|
||||
if (bookingsCount >= maxActiveBookingsPerBooker) {
|
||||
log.warn(`Maximum booking limit reached for ${bookerEmail} for event type ${eventTypeId}`);
|
||||
throw new ErrorWithCode(ErrorCode.BookerLimitExceeded, ErrorCode.BookerLimitExceeded);
|
||||
}
|
||||
};
|
||||
@@ -104,6 +108,7 @@ const checkActiveBookingsLimitAndOfferReschedule = async ({
|
||||
const lastBooking = bookingsCount[bookingsCount.length - 1];
|
||||
|
||||
if (bookingsCount.length >= maxActiveBookingsPerBooker) {
|
||||
log.warn(`Maximum booking limit reached for ${bookerEmail} for event type ${eventTypeId}`);
|
||||
throw new ErrorWithCode(
|
||||
ErrorCode.BookerLimitExceededReschedule,
|
||||
ErrorCode.BookerLimitExceededReschedule,
|
||||
|
||||
Reference in New Issue
Block a user