From 52a52a3e374c08b3b0a87e31a99b639e44943d92 Mon Sep 17 00:00:00 2001 From: chronark Date: Mon, 31 Mar 2025 16:33:55 +0200 Subject: [PATCH] fix: use only time as cursos --- apps/dashboard/app/auth/layout.tsx | 14 +++++++-- .../dashboard/lib/trpc/routers/audit/fetch.ts | 29 ++++--------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/apps/dashboard/app/auth/layout.tsx b/apps/dashboard/app/auth/layout.tsx index 7984e4e504..f50fe55c3d 100644 --- a/apps/dashboard/app/auth/layout.tsx +++ b/apps/dashboard/app/auth/layout.tsx @@ -109,11 +109,21 @@ export default async function AuthenticatedLayout({

By continuing, you agree to Unkey's{" "} - + Terms of Service {" "} and{" "} - + Privacy Policy , and to receive periodic emails with updates. diff --git a/apps/dashboard/lib/trpc/routers/audit/fetch.ts b/apps/dashboard/lib/trpc/routers/audit/fetch.ts index 373301b1c6..d65fa32cf2 100644 --- a/apps/dashboard/lib/trpc/routers/audit/fetch.ts +++ b/apps/dashboard/lib/trpc/routers/audit/fetch.ts @@ -10,12 +10,7 @@ import { transformFilters } from "./utils"; const AuditLogsResponse = z.object({ auditLogs: z.array(auditLog), hasMore: z.boolean(), - nextCursor: z - .object({ - time: z.number().int(), - auditId: z.string(), - }) - .optional(), + nextCursor: z.number().optional(), }); type AuditLogsResponse = z.infer; @@ -70,13 +65,7 @@ export const fetchAuditLog = t.procedure return { auditLogs: items, hasMore, - nextCursor: - hasMore && items.length > 0 - ? { - time: items[items.length - 1].auditLog.time, - auditId: items[items.length - 1].auditLog.id, - } - : undefined, + nextCursor: hasMore && items.length > 0 ? items[items.length - 1].auditLog.time : undefined, }; }); @@ -89,10 +78,7 @@ export const queryAuditLogs = async ( const rootKeyValues = (params.rootKeys ?? []).map((r) => r.value); const users = [...userValues, ...rootKeyValues]; - const cursor = - params.cursorTime !== null && params.cursorAuditId !== null - ? { time: params.cursorTime, auditId: params.cursorAuditId } - : null; + const cursor = params.cursorTime !== null ? { time: params.cursorTime } : null; const retentionDays = (workspace.features.auditLogRetentionDays ?? workspace.plan === "free") ? 30 : 90; @@ -110,17 +96,12 @@ export const queryAuditLogs = async ( params.endTime ?? Date.now(), ), users.length > 0 ? inArray(table.actorId, users) : undefined, - cursor - ? or( - lt(table.time, cursor.time), - and(eq(table.time, cursor.time), lt(table.id, cursor.auditId)), - ) - : undefined, + cursor ? or(lt(table.time, cursor.time)) : undefined, ), with: { targets: true, }, - orderBy: (table, { desc }) => desc(table.id), + orderBy: (table, { desc }) => desc(table.time), limit: params.limit + 1, });