Fix round completion rate: use evaluations/assignments, closed rounds=100%
The round breakdown was showing 200% for active rounds (assignments/projects) and 0% for closed rounds. Now correctly computes evaluations/assignments for active rounds and shows 100% for closed/archived rounds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,10 @@ export const programRouter = router({
|
||||
_count: {
|
||||
select: { assignments: true, projectRoundStates: true },
|
||||
},
|
||||
assignments: {
|
||||
where: { evaluation: { status: 'SUBMITTED' } },
|
||||
select: { id: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -52,9 +56,11 @@ export const programRouter = router({
|
||||
// Provide `stages` as alias for backward compatibility
|
||||
stages: allRounds.map((round: any) => ({
|
||||
...round,
|
||||
assignments: undefined, // don't leak raw assignments array
|
||||
_count: {
|
||||
projects: round._count?.projectRoundStates || 0,
|
||||
assignments: round._count?.assignments || 0,
|
||||
evaluations: round.assignments?.length || 0,
|
||||
},
|
||||
})),
|
||||
// Main rounds array
|
||||
@@ -68,6 +74,7 @@ export const programRouter = router({
|
||||
_count: {
|
||||
projects: round._count?.projectRoundStates || 0,
|
||||
assignments: round._count?.assignments || 0,
|
||||
evaluations: round.assignments?.length || 0,
|
||||
},
|
||||
})),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user