From 07dd7a06929149b66e7a768fe6d5fdb94362ded4 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 24 Apr 2026 16:07:26 +0200 Subject: [PATCH] fix: scope analytics assignments to selected round getProjectRankings and getAllProjects in the analytics router were loading every assignment for each project regardless of the selected round, so per-round rankings in the admin reports were counting evaluations from prior rounds and mixing their scores into averages. A Round 2 view with 3 reviews per project was showing 5 evaluations and a skewed average that included Round 1 data. Filter the nested assignments include by the round (or program) the request is scoped to, matching the pattern already used by the ranking service and by getStatusBreakdown. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/server/routers/analytics.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server/routers/analytics.ts b/src/server/routers/analytics.ts index a901500..951573e 100644 --- a/src/server/routers/analytics.ts +++ b/src/server/routers/analytics.ts @@ -198,6 +198,7 @@ export const analyticsRouter = router({ teamName: true, status: true, assignments: { + where: assignmentWhere(input), select: { evaluation: { select: { criterionScoresJson: true, status: true }, @@ -1072,6 +1073,7 @@ export const analyticsRouter = router({ logoKey: true, logoProvider: true, assignments: { + where: input.roundId ? { roundId: input.roundId } : undefined, select: { roundId: true, round: { select: { id: true, name: true, sortOrder: true } },