fix: getBookings max 1 month in the past when no date filters specified (#20911)

* fix: getBookings max 1 month in the past

* bump platform libraries
This commit is contained in:
Morgan authored and GitHub committed 2025-04-23 13:22:20 -03:00
1 parent a957c15062
commit ec88f16f1f
2 files changed
+21 -1

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@
"@axiomhq/winston": "^1.2.0", "@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*", "@calcom/platform-constants": "*",
"@calcom/platform-enums": "*", "@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/[email protected]4", "@calcom/platform-libraries": "npm:@calcom/[email protected]6",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]", "@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
"@calcom/platform-types": "*", "@calcom/platform-types": "*",
"@calcom/platform-utils": "*", "@calcom/platform-utils": "*",
@@ -334,6 +334,26 @@ export async function getBookings({
andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } }); andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
} }
// All the possible date filter keys
const dateFilterKeys = [
"afterStartDate",
"beforeEndDate",
"afterUpdatedDate",
"beforeUpdatedDate",
"afterCreatedDate",
"beforeCreatedDate",
] as const;
const hasAnyDateFilter = dateFilterKeys.some((key) => filters?.[key]);
if (!hasAnyDateFilter) {
// is ORG/TEAM admin/owner
if (userIdsWhereUserIsAdminOrOwner?.length || userEmailsWhereUserIsAdminOrOwner?.length) {
const oneMonthAgo = dayjs.utc().subtract(1, "month").startOf("day").toDate();
andConditions.push({ startTime: { gte: oneMonthAgo } });
}
}
const whereClause = { const whereClause = {
OR: orConditions, OR: orConditions,
AND: andConditions, AND: andConditions,