From c6f7be40df7c37d087755c29260120b0a63f6fae Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 29 Oct 2025 16:16:25 -0700 Subject: [PATCH] Sort by descending --- server/private/routers/auditLogs/queryAccessAuditLog.ts | 4 ++-- server/private/routers/auditLogs/queryActionAuditLog.ts | 4 ++-- server/routers/auditLogs/queryRequstAuditLog.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/private/routers/auditLogs/queryAccessAuditLog.ts b/server/private/routers/auditLogs/queryAccessAuditLog.ts index d6c9dea6..4d6b96e6 100644 --- a/server/private/routers/auditLogs/queryAccessAuditLog.ts +++ b/server/private/routers/auditLogs/queryAccessAuditLog.ts @@ -15,7 +15,7 @@ import { accessAuditLog, db, resources } from "@server/db"; import { registry } from "@server/openApi"; import { NextFunction } from "express"; import { Request, Response } from "express"; -import { eq, gt, lt, and, count } from "drizzle-orm"; +import { eq, gt, lt, and, count, desc } from "drizzle-orm"; import { OpenAPITags } from "@server/openApi"; import { z } from "zod"; import createHttpError from "http-errors"; @@ -124,7 +124,7 @@ export function queryAccess(data: Q) { eq(accessAuditLog.resourceId, resources.resourceId) ) .where(getWhere(data)) - .orderBy(accessAuditLog.timestamp); + .orderBy(desc(accessAuditLog.timestamp)); } export function countAccessQuery(data: Q) { diff --git a/server/private/routers/auditLogs/queryActionAuditLog.ts b/server/private/routers/auditLogs/queryActionAuditLog.ts index f9dcbbf5..f3796aa2 100644 --- a/server/private/routers/auditLogs/queryActionAuditLog.ts +++ b/server/private/routers/auditLogs/queryActionAuditLog.ts @@ -15,7 +15,7 @@ import { actionAuditLog, db } from "@server/db"; import { registry } from "@server/openApi"; import { NextFunction } from "express"; import { Request, Response } from "express"; -import { eq, gt, lt, and, count } from "drizzle-orm"; +import { eq, gt, lt, and, count, desc } from "drizzle-orm"; import { OpenAPITags } from "@server/openApi"; import { z } from "zod"; import createHttpError from "http-errors"; @@ -92,7 +92,7 @@ export function queryAction(data: Q) { }) .from(actionAuditLog) .where(getWhere(data)) - .orderBy(actionAuditLog.timestamp); + .orderBy(desc(actionAuditLog.timestamp)); } export function countActionQuery(data: Q) { diff --git a/server/routers/auditLogs/queryRequstAuditLog.ts b/server/routers/auditLogs/queryRequstAuditLog.ts index d41b14b6..5575f8bd 100644 --- a/server/routers/auditLogs/queryRequstAuditLog.ts +++ b/server/routers/auditLogs/queryRequstAuditLog.ts @@ -2,7 +2,7 @@ import { db, requestAuditLog, resources } from "@server/db"; import { registry } from "@server/openApi"; import { NextFunction } from "express"; import { Request, Response } from "express"; -import { eq, gt, lt, and, count } from "drizzle-orm"; +import { eq, gt, lt, and, count, desc } from "drizzle-orm"; import { OpenAPITags } from "@server/openApi"; import { z } from "zod"; import createHttpError from "http-errors"; @@ -123,7 +123,7 @@ export function queryRequest(data: Q) { eq(requestAuditLog.resourceId, resources.resourceId) ) // TODO: Is this efficient? .where(getWhere(data)) - .orderBy(requestAuditLog.timestamp); + .orderBy(desc(requestAuditLog.timestamp)); } export function countRequestQuery(data: Q) {