diff --git a/src/app/(admin)/admin/rounds/page.tsx b/src/app/(admin)/admin/rounds/page.tsx index 3633796..2da7ccf 100644 --- a/src/app/(admin)/admin/rounds/page.tsx +++ b/src/app/(admin)/admin/rounds/page.tsx @@ -283,7 +283,7 @@ export default function RoundsPage() { // ─── Main Render ───────────────────────────────────────────────────────── const activeFilter = filterType !== 'all' - const totalProjects = rounds.reduce((s, r) => s + r._count.projectRoundStates, 0) + const totalProjects = (compDetail as any)?.distinctProjectCount ?? 0 const totalAssignments = rounds.reduce((s, r) => s + r._count.assignments, 0) const activeRound = rounds.find((r) => r.status === 'ROUND_ACTIVE') diff --git a/src/server/routers/competition.ts b/src/server/routers/competition.ts index 4bcb077..6ee3472 100644 --- a/src/server/routers/competition.ts +++ b/src/server/routers/competition.ts @@ -122,7 +122,17 @@ export const competitionRouter = router({ throw new TRPCError({ code: 'NOT_FOUND', message: 'Competition not found' }) } - return competition + // Count distinct projects across all rounds (not sum of per-round states) + const roundIds = competition.rounds.map((r) => r.id) + const distinctProjectCount = roundIds.length > 0 + ? await ctx.prisma.projectRoundState.findMany({ + where: { roundId: { in: roundIds } }, + select: { projectId: true }, + distinct: ['projectId'], + }).then((rows) => rows.length) + : 0 + + return { ...competition, distinctProjectCount } }), /**