From be4449e4ef7ce263e69cfb613ec2f267155d12b1 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 23 Apr 2026 14:03:26 +0200 Subject: [PATCH] fix: surface advance-type criterion in ranking yes/no counts The ranking dashboard showed 0/X Yes for every project in rounds using the 'advance' criterion type because the matcher only looked for type === 'boolean' with a "move to the next stage" label. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/server/routers/ranking.ts | 10 ++++++---- src/server/services/ai-ranking.ts | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/server/routers/ranking.ts b/src/server/routers/ranking.ts index bdb46d7..0a17e81 100644 --- a/src/server/routers/ranking.ts +++ b/src/server/routers/ranking.ts @@ -443,7 +443,9 @@ export const rankingRouter = router({ roundEvaluationScores: adminProcedure .input(z.object({ roundId: z.string() })) .query(async ({ ctx, input }) => { - // Find the boolean criterion ID across all active forms (shared + category-specific) + // Find the advance-decision criterion ID across all active forms (shared + category-specific). + // Current forms use type === 'advance' (one allowed per form). Legacy forms used + // type === 'boolean' with a "move to the next stage" label. const activeForms = await ctx.prisma.evaluationForm.findMany({ where: { roundId: input.roundId, isActive: true }, select: { criteriaJson: true }, @@ -453,9 +455,9 @@ export const rankingRouter = router({ const fc = (f.criteriaJson as Array<{ id: string; label: string; type?: string }> | null) ?? [] - const found = fc.find( - (c) => c.type === 'boolean' && c.label?.toLowerCase().includes('move to the next stage'), - ) + const found = + fc.find((c) => c.type === 'advance') ?? + fc.find((c) => c.type === 'boolean' && c.label?.toLowerCase().includes('move to the next stage')) if (found) { boolCriterionId = found.id break diff --git a/src/server/services/ai-ranking.ts b/src/server/services/ai-ranking.ts index 527c0e1..1f45917 100644 --- a/src/server/services/ai-ranking.ts +++ b/src/server/services/ai-ranking.ts @@ -256,10 +256,14 @@ function anonymizeProjectsForRanking( } /** - * Find the boolean criterion ID for "Move to the Next Stage?" from criteria definitions. + * Find the advance-decision criterion ID from criteria definitions. + * Current forms use type === 'advance' (one allowed per form). Legacy forms used + * type === 'boolean' with a "move to the next stage" label. * Accepts criteria from EvaluationForm.criteriaJson (preferred) or round configJson (legacy). */ function findBooleanCriterionId(criterionDefs: Array<{ id: string; label: string; type?: string }>): string | null { + const advanceCriterion = criterionDefs.find((c) => c.type === 'advance') + if (advanceCriterion) return advanceCriterion.id const boolCriterion = criterionDefs.find( (c) => c.type === 'boolean' && c.label?.toLowerCase().includes('move to the next stage'), )