Add 5-second auto-refresh for dashboard Activity feed
All checks were successful
Build and Push Docker Image / build (push) Successful in 9m0s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 17:15:42 +01:00
parent feccd269f7
commit ab2c73bad2
2 changed files with 23 additions and 1 deletions

View File

@@ -121,6 +121,10 @@ export function DashboardContent({ editionId, sessionName }: DashboardContentPro
{ editionId, limit: 8 },
{ enabled: !!editionId, refetchInterval: 30_000 }
)
const { data: liveActivity } = trpc.dashboard.getRecentActivity.useQuery(
{ limit: 8 },
{ enabled: !!editionId, refetchInterval: 5_000 }
)
if (isLoading) {
return <DashboardSkeleton />
@@ -268,7 +272,7 @@ export function DashboardContent({ editionId, sessionName }: DashboardContentPro
</AnimatedCard>
<AnimatedCard index={6}>
<ActivityFeed activity={recentActivity} />
<ActivityFeed activity={liveActivity ?? recentActivity} />
</AnimatedCard>
</div>
</div>

View File

@@ -553,4 +553,22 @@ export const dashboardRouter = router({
return evaluations
}),
getRecentActivity: adminProcedure
.input(z.object({ limit: z.number().int().min(1).max(20).optional() }))
.query(async ({ ctx, input }) => {
const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
return ctx.prisma.auditLog.findMany({
where: { timestamp: { gte: sevenDaysAgo } },
orderBy: { timestamp: 'desc' },
take: input.limit ?? 8,
select: {
id: true,
action: true,
entityType: true,
timestamp: true,
user: { select: { name: true } },
},
})
}),
})