Scheduling infrastructure for absolutely everyone.
perf: optimize app registry performance with caching (#22632)
Anik Dhabal Babu5a350efb4073
diff --git a/packages/lib/apps/getInstallCountPerApp.ts b/packages/lib/apps/getInstallCountPerApp.tsindex f74901a566b..482313e7ab5 100644--- a/packages/lib/apps/getInstallCountPerApp.ts+++ b/packages/lib/apps/getInstallCountPerApp.ts@@ -1,8 +1,9 @@+import { unstable_cache } from "next/cache";import { z } from "zod";import prisma from "@calcom/prisma";-const getInstallCountPerApp = async () => {+const computeInstallCountsFromDB = async (): Promise<Record<string, number>> => {const mostPopularApps = z.array(z.object({ appId: z.string(), installCount: z.number() })).parse(await prisma.$queryRaw`SELECT@@ -24,4 +25,12 @@ const getInstallCountPerApp = async () => {}, {} as Record<string, number>);};+const getInstallCountPerApp = async (): Promise<Record<string, number>> => {+ return unstable_cache(async () => computeInstallCountsFromDB(), ["app-install-counts"], {+ revalidate: 300,+ tags: ["app-install-counts"],+ })();+};+export default getInstallCountPerApp;+export { computeInstallCountsFromDB };