From 0a63dd561512a2cd2043341462fa88ca208ecc0b Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 4 Dec 2023 22:26:26 +0800 Subject: [PATCH] feat: add limit for monitor events route --- src/server/trpc/routers/monitor.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server/trpc/routers/monitor.ts b/src/server/trpc/routers/monitor.ts index 7db03f0..34f9fb1 100644 --- a/src/server/trpc/routers/monitor.ts +++ b/src/server/trpc/routers/monitor.ts @@ -351,11 +351,12 @@ export const monitorRouter = router({ .input( z.object({ monitorId: z.string().cuid2().optional(), + limit: z.number().default(20), }) ) .output(z.array(monitorEventSchema)) .query(async ({ input }) => { - const { workspaceId, monitorId } = input; + const { workspaceId, monitorId, limit } = input; const list = await prisma.monitorEvent.findMany({ where: { @@ -367,7 +368,7 @@ export const monitorRouter = router({ orderBy: { createdAt: 'desc', }, - take: 20, + take: limit, }); return list;