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,7 +1,4 @@
import type { AppFlags } from "./config";
export interface IFeaturesRepository {
checkIfFeatureIsEnabledGlobally(slug: keyof AppFlags): Promise<boolean>;
checkIfUserHasFeature(userId: number, slug: string): Promise<boolean>;
checkIfTeamHasFeature(teamId: number, slug: string): Promise<boolean>;
checkIfTeamOrUserHasFeature(args: { teamId?: number; userId?: number }, slug: string): Promise<boolean>;
@@ -2,19 +2,9 @@ import { captureException } from "@sentry/nextjs";
import db from "@calcom/prisma";
import type { AppFlags } from "./config";
import type { IFeaturesRepository } from "./features.repository.interface";
import { getFeatureFlag } from "./server/utils";
export class FeaturesRepository implements IFeaturesRepository {
async checkIfFeatureIsEnabledGlobally(slug: keyof AppFlags) {
try {
return await getFeatureFlag(db, slug);
} catch (err) {
captureException(err);
throw err;
}
}
async checkIfTeamHasFeature(teamId: number, slug: string) {
try {
const teamFeature = await db.teamFeatures.findUnique({
+3 -20
View File
@@ -1,26 +1,9 @@
import type { AppFlags } from "@calcom/features/flags/config";
import { trpc } from "@calcom/trpc/react";
const initialData: AppFlags = {
organizations: false,
teams: false,
"calendar-cache": false,
emails: false,
insights: false,
webhooks: false,
workflows: false,
"email-verification": false,
"google-workspace-directory": false,
"disable-signup": false,
attributes: false,
"organizer-request-email-v2": false,
};
if (process.env.NEXT_PUBLIC_IS_E2E) {
initialData.organizations = true;
initialData.teams = true;
}
const initialData: Partial<AppFlags> = process.env.NEXT_PUBLIC_IS_E2E
? { organizations: true, teams: true }
: {};
export function useFlags(): Partial<AppFlags> {
const query = trpc.viewer.features.map.useQuery(undefined, {
initialData,
+2 -8
View File
@@ -2,21 +2,15 @@ import type { PrismaClient } from "@calcom/prisma";
import type { AppFlags } from "../config";
// This is a temporary cache to avoid hitting the database on every lambda invocation
let TEMP_CACHE: AppFlags | null = null;
export async function getFeatureFlagMap(prisma: PrismaClient) {
// If we've already fetched the flags, return them
if (TEMP_CACHE) return TEMP_CACHE;
const flags = await prisma.feature.findMany({
orderBy: { slug: "asc" },
cacheStrategy: { swr: 300, ttl: 300 },
});
TEMP_CACHE = flags.reduce((acc, flag) => {
return flags.reduce((acc, flag) => {
acc[flag.slug as keyof AppFlags] = flag.enabled;
return acc;
}, {} as AppFlags);
return TEMP_CACHE;
}, {} as Partial<AppFlags>);
}
interface CacheEntry {