feat: add limit for monitor events route

This commit is contained in:
moonrailgun 2023-12-04 22:26:26 +08:00
parent addda5c45a
commit 0a63dd5615

View File

@ -351,11 +351,12 @@ export const monitorRouter = router({
.input( .input(
z.object({ z.object({
monitorId: z.string().cuid2().optional(), monitorId: z.string().cuid2().optional(),
limit: z.number().default(20),
}) })
) )
.output(z.array(monitorEventSchema)) .output(z.array(monitorEventSchema))
.query(async ({ input }) => { .query(async ({ input }) => {
const { workspaceId, monitorId } = input; const { workspaceId, monitorId, limit } = input;
const list = await prisma.monitorEvent.findMany({ const list = await prisma.monitorEvent.findMany({
where: { where: {
@ -367,7 +368,7 @@ export const monitorRouter = router({
orderBy: { orderBy: {
createdAt: 'desc', createdAt: 'desc',
}, },
take: 20, take: limit,
}); });
return list; return list;