diff --git a/packages/lib/apps/getInstallCountPerApp.ts b/packages/lib/apps/getInstallCountPerApp.ts index f74901a566..482313e7ab 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> => { 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); }; +const getInstallCountPerApp = async (): Promise> => { + return unstable_cache(async () => computeInstallCountsFromDB(), ["app-install-counts"], { + revalidate: 300, + tags: ["app-install-counts"], + })(); +}; + export default getInstallCountPerApp; +export { computeInstallCountsFromDB };