fix: scope analytics assignments to selected round
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m38s

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) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-04-24 16:07:26 +02:00
parent f36f68bbf9
commit 07dd7a0692

View File

@@ -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 } },