Skip to content

Commit

Permalink
implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaWolli committed Oct 7, 2024
1 parent a1b9ccf commit 537887c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@
"workflow_example_4": "Send email reminder 1 hour before events starts to attendee",
"workflow_example_5": "Send custom email when event is rescheduled to host",
"workflow_example_6": "Send custom SMS when new event is booked to host",
"count_managed_to_limit": "Count bookings from managed event types",
"count_managed_to_limit": "Include booking counts from managed event types",
"welcome_to_cal_header": "Welcome to {{appName}}!",
"edit_form_later_subtitle": "You’ll be able to edit this later.",
"connect_calendar_later": "I'll connect my calendar later",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/bookingLimits/getBusyTimesFromLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const _getBusyTimesFromLimits = async (
duration: number | undefined,
eventType: NonNullable<EventType>,
bookings: EventBusyDetails[],
timeZone?: string | null,
timeZone: string,
rescheduleUid?: string
) => {
performance.mark("limitsStart");
Expand Down Expand Up @@ -240,8 +240,8 @@ const _getBusyTimesFromTeamLimits = async (
dateTo: Dayjs,
teamId: number,
includeManagedEvents: boolean,
rescheduleUid?: string,
timeZone?: string | null
timeZone: string,
rescheduleUid?: string
) => {
const { limitDateFrom, limitDateTo } = getStartEndDateforLimitCheck(
dateFrom.toISOString(),
Expand Down
8 changes: 4 additions & 4 deletions packages/core/getUserAvailability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
duration,
eventType,
initialData?.busyTimesFromLimitsBookings ?? [],
initialData?.rescheduleUid ?? undefined,
timeZone
timeZone,
initialData?.rescheduleUid ?? undefined
)
: [];

Expand All @@ -318,8 +318,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
dateTo.tz(timeZone),
teamForBookingLimits.id,
teamForBookingLimits.includeManagedEventsInLimits,
initialData?.rescheduleUid ?? undefined,
timeZone
timeZone,
initialData?.rescheduleUid ?? undefined
)
: [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe(
})
);

const mockBookingData1 = getMockRequestDataForBooking({
const mockBookingWithinLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-08T04:00:00.000Z`,
end: `2024-08-08T04:30:00.000Z`,
Expand All @@ -175,7 +175,7 @@ describe(

const { req: req1 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData1,
body: mockBookingWithinLimit,
});

const createdBooking = await handleNewBooking(req1);
Expand All @@ -187,7 +187,7 @@ describe(
})
);

const mockBookingData2 = getMockRequestDataForBooking({
const mockBookingAboveLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-08T04:00:00.000Z`,
end: `2024-08-08T04:30:00.000Z`,
Expand All @@ -202,10 +202,10 @@ describe(

const { req: req2 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData2,
body: mockBookingAboveLimit,
});

// this is the thrid team booking of this week for user 101, limit reached
// this is the third team booking of this week for user 101, limit reached
await expect(async () => await handleNewBooking(req2)).rejects.toThrowError(
"no_available_users_found_error"
);
Expand Down Expand Up @@ -251,7 +251,7 @@ describe(
})
);

const mockBookingData1 = getMockRequestDataForBooking({
const mockBookingWithinLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-07T04:30:00.000Z`,
end: `2024-08-07T05:00:00.000Z`,
Expand All @@ -266,7 +266,7 @@ describe(

const { req: req1 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData1,
body: mockBookingWithinLimit,
});

const createdBooking = await handleNewBooking(req1);
Expand All @@ -278,7 +278,7 @@ describe(
})
);

const mockBookingData2 = getMockRequestDataForBooking({
const mockBookingAboveLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-07T04:00:00.000Z`,
end: `2024-08-07T04:30:00.000Z`,
Expand All @@ -293,7 +293,7 @@ describe(

const { req: req2 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData1,
body: mockBookingAboveLimit,
});

// this is the second team booking of this day for user 101, limit reached
Expand Down Expand Up @@ -387,7 +387,7 @@ describe(
})
);

const mockBookingData1 = getMockRequestDataForBooking({
const mockBookingWithinLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-29T04:30:00.000Z`,
end: `2024-08-29T05:00:00.000Z`,
Expand All @@ -402,7 +402,7 @@ describe(

const { req: req1 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData1,
body: mockBookingWithinLimit,
});

const createdBooking = await handleNewBooking(req1);
Expand All @@ -414,7 +414,7 @@ describe(
})
);

const mockBookingData2 = getMockRequestDataForBooking({
const mockBookingAboveLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-25T04:00:00.000Z`,
end: `2024-08-25T04:30:00.000Z`,
Expand All @@ -429,7 +429,7 @@ describe(

const { req: req2 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData2,
body: mockBookingAboveLimit,
});

// this is the firth team booking (incl. managed) of this month for user 101, limit reached
Expand Down Expand Up @@ -515,7 +515,7 @@ describe(
})
);

const mockBookingData1 = getMockRequestDataForBooking({
const mockBookingWithinLimit = getMockRequestDataForBooking({
data: {
start: `2024-08-29T04:30:00.000Z`,
end: `2024-08-29T05:00:00.000Z`,
Expand All @@ -530,7 +530,7 @@ describe(

const { req: req1 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData1,
body: mockBookingWithinLimit,
});

const createdBooking = await handleNewBooking(req1);
Expand All @@ -542,7 +542,7 @@ describe(
})
);

const mockBookingData2 = getMockRequestDataForBooking({
const mockBookingAboveLimit = getMockRequestDataForBooking({
data: {
start: `2024-11-25T04:00:00.000Z`,
end: `2024-11-25T04:30:00.000Z`,
Expand All @@ -557,7 +557,7 @@ describe(

const { req: req2 } = createMockNextJsRequest({
method: "POST",
body: mockBookingData2,
body: mockBookingAboveLimit,
});

await expect(async () => await handleNewBooking(req2)).rejects.toThrowError(
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/server/checkBookingLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function checkBookingLimit({
teamId,
startDate: startDate,
endDate: endDate,
returnCount: true,
shouldReturnCount: true,
excludedUid: rescheduleUid,
includeManagedEvents,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/lib/server/repository/booking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type TeamBookingsParamsBase = {
endDate: Date;
excludedUid?: string | null;
includeManagedEvents: boolean;
returnCount?: boolean;
shouldReturnCount?: boolean;
};

type TeamBookingsParamsWithCount = TeamBookingsParamsBase & {
returnCount: true;
shouldReturnCount: true;
};

type TeamBookingsParamsWithoutCount = TeamBookingsParamsBase;
Expand Down Expand Up @@ -274,7 +274,7 @@ export class BookingRepository {
): Promise<Array<Booking>>;

static async getAllAcceptedTeamBookingsOfUser(params: TeamBookingsParamsBase) {
const { user, teamId, startDate, endDate, excludedUid, returnCount, includeManagedEvents } = params;
const { user, teamId, startDate, endDate, excludedUid, shouldReturnCount, includeManagedEvents } = params;

const baseWhere: Prisma.BookingWhereInput = {
status: BookingStatus.ACCEPTED,
Expand Down Expand Up @@ -321,7 +321,7 @@ export class BookingRepository {
},
};

if (returnCount) {
if (shouldReturnCount) {
const collectiveRoundRobinBookingsOwner = await prisma.booking.count({
where: whereCollectiveRoundRobinOwner,
});
Expand Down

0 comments on commit 537887c

Please sign in to comment.