fix: scope analytics.getProjectDetail by optional roundId

The procedure pulled every SUBMITTED evaluation for a project across
every round it ever participated in, then computed Avg Score / Pass
Rate / Evaluators from that pool. Meanwhile the per-juror list rendered
in the admin sheet filters to the current round, producing a card that
disagreed with the visible list. With roundId in the input, callers
opt into round-scoped stats; omitting it preserves the old aggregate
behavior for any caller that hasn't been updated yet.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-04-27 13:12:27 +02:00
parent 260baf3a41
commit 7147115918
2 changed files with 77 additions and 2 deletions

View File

@@ -1368,7 +1368,7 @@ export const analyticsRouter = router({
* Read-only combined endpoint to avoid multiple round-trips.
*/
getProjectDetail: observerProcedure
.input(z.object({ id: z.string() }))
.input(z.object({ id: z.string(), roundId: z.string().optional() }))
.query(async ({ ctx, input }) => {
const [projectRaw, projectTags, assignments, submittedEvaluations] = await Promise.all([
ctx.prisma.project.findUniqueOrThrow({
@@ -1417,7 +1417,10 @@ export const analyticsRouter = router({
ctx.prisma.evaluation.findMany({
where: {
status: 'SUBMITTED',
assignment: { projectId: input.id },
assignment: {
projectId: input.id,
...(input.roundId ? { roundId: input.roundId } : {}),
},
},
}),
])