Fix audit log not showing latest logs

This commit is contained in:
2026-01-22 17:32:12 +07:00 Unverified
parent d8daaed36c
commit 805175682f
2 changed files with 22 additions and 8 deletions
+11 -3
View File
@@ -1,9 +1,10 @@
"use client";
import { ChevronDown, ChevronRight } from "lucide-react";
import { ChevronDown, ChevronRight, CircleAlert } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { stringify } from "yaml";
import SearchBox, { type Filters, type ParsedQuery } from "@/components/search";
import { SimpleTooltip } from "@/components/tooltip";
import { Button } from "@/components/ui/button";
import type { auditLog } from "@/lib/db/schema";
@@ -173,8 +174,15 @@ export default function AuditLogViewer({
onClick={() => toggleExpand(log.id)}
role="tree"
>
<span className="text-gray-300 leading-relaxed">
{log.text}
<span className="text-gray-300 leading-relaxed flex items-center gap-2">
{log.text}{" "}
{!isExpanded && log.details ? (
<SimpleTooltip text="Click to see details">
<CircleAlert className="opacity-80 size-4" />
</SimpleTooltip>
) : (
""
)}
</span>
{log.details ? (
<Button
+11 -5
View File
@@ -1,13 +1,19 @@
import { sql } from "drizzle-orm";
import { db } from "@/lib/db";
import { auditLog, user } from "@/lib/db/schema";
import AuditLogViewer from "./client";
export default async function AuditLogViewerPage() {
const logs = await db
.select()
.from(auditLog)
.orderBy(auditLog.time)
.limit(1000);
const { rows: logs } = (await db.execute(sql`
SELECT *
FROM (
SELECT *
FROM ${auditLog}
ORDER BY ${auditLog.id} DESC
LIMIT 1000
) t
ORDER BY id ASC;
`)) as { rows: (typeof auditLog.$inferSelect)[] };
const users = await db
.select({ name: user.name, email: user.email })
.from(user);