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

This reverts commit d294a74aad.
This commit is contained in:
Keith Williams authored and GitHub committed 2024-11-15 19:28:30 -03:00
1 parent bdf94c7f48
commit 6272c881c8
39 files changed
+240 -952

No files matched your search

@@ -1,15 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[googleChannelId]` on the table `SelectedCalendar` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "SelectedCalendar" ADD COLUMN "googleChannelExpiration" TEXT,
ADD COLUMN "googleChannelId" TEXT,
ADD COLUMN "googleChannelKind" TEXT,
ADD COLUMN "googleChannelResourceId" TEXT,
ADD COLUMN "googleChannelResourceUri" TEXT;
-- CreateIndex
CREATE UNIQUE INDEX "SelectedCalendar_googleChannelId_key" ON "SelectedCalendar"("googleChannelId");
+6 -12
View File
@@ -682,18 +682,12 @@ model Availability {
}
model SelectedCalendar {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
integration String
externalId String
credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
credentialId Int?
// Used to identify a watched calendar channel in Google Calendar
googleChannelId String? @unique
googleChannelKind String?
googleChannelResourceId String?
googleChannelResourceUri String?
googleChannelExpiration String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
integration String
externalId String
credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
credentialId Int?
@@id([userId, integration, externalId])
@@index([userId])
@@ -1,24 +0,0 @@
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
)
);