fix: single rejection caused cache cron to fail (#18239)
This commit is contained in:
@@ -41,22 +41,11 @@ const handleCalendarsToWatch = async () => {
|
||||
// This cron is used to activate and renew calendar subcriptions
|
||||
const handler = defaultResponder(async (request: NextApiRequest) => {
|
||||
validateRequest(request);
|
||||
const [watchedResult, unwatchedResult] = await Promise.all([
|
||||
handleCalendarsToWatch(),
|
||||
handleCalendarsToUnwatch(),
|
||||
]);
|
||||
await Promise.allSettled([handleCalendarsToWatch(), handleCalendarsToUnwatch()]);
|
||||
|
||||
// TODO: Credentials can be installed on a whole team, check for selected calendars on the team
|
||||
return {
|
||||
succeededAt: new Date().toISOString(),
|
||||
watched: {
|
||||
successful: watchedResult.filter((x) => x.status === "fulfilled").length,
|
||||
failed: watchedResult.filter((x) => x.status === "rejected").length,
|
||||
},
|
||||
unwatched: {
|
||||
successful: unwatchedResult.filter((x) => x.status === "fulfilled").length,
|
||||
failed: unwatchedResult.filter((x) => x.status === "rejected").length,
|
||||
},
|
||||
executedAt: new Date().toISOString(),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
|
||||
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
|
||||
@@ -64,12 +63,7 @@ export class SelectedCalendarRepository {
|
||||
// RN we only support google calendar subscriptions for now
|
||||
integration: "google_calendar",
|
||||
googleChannelExpiration: { not: null },
|
||||
};
|
||||
const featureRepo = new FeaturesRepository();
|
||||
const calendarCache = await featureRepo.checkIfFeatureIsEnabledGlobally("calendar-cache");
|
||||
// If calendar cache is disabled globally, we skip team features and unwatch all subscriptions
|
||||
if (!calendarCache) {
|
||||
where.user = {
|
||||
user: {
|
||||
teams: {
|
||||
every: {
|
||||
team: {
|
||||
@@ -81,8 +75,9 @@ export class SelectedCalendarRepository {
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
// If calendar cache is disabled globally, we skip team features and unwatch all subscriptions
|
||||
const nextBatch = await prisma.selectedCalendar.findMany({
|
||||
take: limit,
|
||||
where,
|
||||
|
||||
Reference in New Issue
Block a user