diff --git a/src/app/(admin)/admin/projects/page.tsx b/src/app/(admin)/admin/projects/page.tsx
index 66f0550..778fc9d 100644
--- a/src/app/(admin)/admin/projects/page.tsx
+++ b/src/app/(admin)/admin/projects/page.tsx
@@ -711,13 +711,7 @@ export default function ProjectsPage() {
{data && data.projects.length > 0 && (
- {Object.entries(
- data.projects.reduce>((acc, p) => {
- const s = p.status ?? 'SUBMITTED'
- acc[s] = (acc[s] || 0) + 1
- return acc
- }, {})
- )
+ {Object.entries(data.statusCounts ?? {})
.sort(([a], [b]) => {
const order = ['SUBMITTED', 'ELIGIBLE', 'ASSIGNED', 'SEMIFINALIST', 'FINALIST', 'WINNER', 'REJECTED', 'WITHDRAWN']
return order.indexOf(a) - order.indexOf(b)
diff --git a/src/server/routers/project.ts b/src/server/routers/project.ts
index 3ab4bab..d085b00 100644
--- a/src/server/routers/project.ts
+++ b/src/server/routers/project.ts
@@ -140,7 +140,7 @@ export const projectRouter = router({
}
}
- const [projects, total] = await Promise.all([
+ const [projects, total, statusGroups] = await Promise.all([
ctx.prisma.project.findMany({
where,
skip,
@@ -152,14 +152,26 @@ export const projectRouter = router({
},
}),
ctx.prisma.project.count({ where }),
+ ctx.prisma.project.groupBy({
+ by: ['status'],
+ where,
+ _count: true,
+ }),
])
+ // Build status counts from groupBy (across all pages)
+ const statusCounts: Record = {}
+ for (const g of statusGroups) {
+ statusCounts[g.status] = g._count
+ }
+
return {
projects,
total,
page,
perPage,
totalPages: Math.ceil(total / perPage),
+ statusCounts,
}
}),