revert: "feat: Populate gCal calendar cache via webhooks (#11928)"" (#17682)

This commit is contained in:
Omar López authored and GitHub committed 2024-11-18 19:48:33 +00:00
1 parent 50df22928b
commit 7c0ee9f186
38 files changed
+920 -240

No files matched your search

@@ -0,0 +1,24 @@
SELECT
TO_TIMESTAMP(sc."googleChannelExpiration"::bigint / 1000 - 86400)::date as "humanReadableExpireDate",
sc.*
FROM
"SelectedCalendar" sc
LEFT JOIN "users" AS u ON u.id = sc. "userId"
LEFT JOIN "Membership" AS m ON m. "userId" = u.id
LEFT JOIN "Team" AS t ON t.id = m."teamId"
LEFT JOIN "TeamFeatures" AS tf ON tf. "teamId" = t.id
WHERE
-- Only get calendars for teams where cache is enabled
tf."featureId" = 'calendar-cache'
-- We currently only support google watchers
AND sc."integration" = 'google_calendar'
AND (
-- Either is a calendar pending to be watched
sc."googleChannelExpiration" IS NULL
OR (
-- Or is a calendar that is about to expire
sc."googleChannelExpiration" IS NOT NULL
-- We substract one day in senconds to renew a day before expiration
AND TO_TIMESTAMP(sc."googleChannelExpiration"::bigint / 1000 - 86400)::date < CURRENT_TIMESTAMP
)
);