File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { unstable_cache } from "next/cache" ;
1
2
import { z } from "zod" ;
2
3
3
4
import prisma from "@calcom/prisma" ;
4
5
5
- const getInstallCountPerApp = async ( ) => {
6
+ const computeInstallCountsFromDB = async ( ) : Promise < Record < string , number > > => {
6
7
const mostPopularApps = z . array ( z . object ( { appId : z . string ( ) , installCount : z . number ( ) } ) ) . parse (
7
8
await prisma . $queryRaw `
8
9
SELECT
@@ -24,4 +25,12 @@ const getInstallCountPerApp = async () => {
24
25
} , { } as Record < string , number > ) ;
25
26
} ;
26
27
28
+ const getInstallCountPerApp = async ( ) : Promise < Record < string , number > > => {
29
+ return unstable_cache ( async ( ) => computeInstallCountsFromDB ( ) , [ "app-install-counts" ] , {
30
+ revalidate : 300 ,
31
+ tags : [ "app-install-counts" ] ,
32
+ } ) ( ) ;
33
+ } ;
34
+
27
35
export default getInstallCountPerApp ;
36
+ export { computeInstallCountsFromDB } ;
You can’t perform that action at this time.
0 commit comments