Add 5-second auto-refresh for dashboard Activity feed
All checks were successful
Build and Push Docker Image / build (push) Successful in 9m0s
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:
@@ -121,6 +121,10 @@ export function DashboardContent({ editionId, sessionName }: DashboardContentPro
|
|||||||
{ editionId, limit: 8 },
|
{ editionId, limit: 8 },
|
||||||
{ enabled: !!editionId, refetchInterval: 30_000 }
|
{ enabled: !!editionId, refetchInterval: 30_000 }
|
||||||
)
|
)
|
||||||
|
const { data: liveActivity } = trpc.dashboard.getRecentActivity.useQuery(
|
||||||
|
{ limit: 8 },
|
||||||
|
{ enabled: !!editionId, refetchInterval: 5_000 }
|
||||||
|
)
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <DashboardSkeleton />
|
return <DashboardSkeleton />
|
||||||
@@ -268,7 +272,7 @@ export function DashboardContent({ editionId, sessionName }: DashboardContentPro
|
|||||||
</AnimatedCard>
|
</AnimatedCard>
|
||||||
|
|
||||||
<AnimatedCard index={6}>
|
<AnimatedCard index={6}>
|
||||||
<ActivityFeed activity={recentActivity} />
|
<ActivityFeed activity={liveActivity ?? recentActivity} />
|
||||||
</AnimatedCard>
|
</AnimatedCard>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -553,4 +553,22 @@ export const dashboardRouter = router({
|
|||||||
|
|
||||||
return evaluations
|
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 } },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user