fix: harden award track filtering edge cases in applicant portal
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

- getNavFlags/getMyEvaluations: return empty when project has no round
  states instead of dropping the filter (prevented phantom eval rounds)
- getUpcomingDeadlines: detect isInAwardTrack from ProjectRoundState
  join instead of pre-filtered deadline rounds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 00:27:53 +01:00
parent d183d98d9a
commit ebc6331d1f

View File

@@ -1431,15 +1431,17 @@ export const applicantRouter = router({
})).map((prs) => prs.roundId)
)
const closedEvalRounds = await ctx.prisma.round.findMany({
where: {
competition: { programId: project.programId },
roundType: 'EVALUATION',
status: { in: ['ROUND_CLOSED', 'ROUND_ARCHIVED'] },
...(projectRoundIds.size > 0 ? { id: { in: [...projectRoundIds] } } : {}),
},
select: { configJson: true },
})
const closedEvalRounds = projectRoundIds.size > 0
? await ctx.prisma.round.findMany({
where: {
competition: { programId: project.programId },
roundType: 'EVALUATION',
status: { in: ['ROUND_CLOSED', 'ROUND_ARCHIVED'] },
id: { in: [...projectRoundIds] },
},
select: { configJson: true },
})
: []
hasEvaluationRounds = closedEvalRounds.some((r) => {
const parsed = EvaluationConfigSchema.safeParse(r.configJson)
return parsed.success && parsed.data.applicantVisibility.enabled
@@ -1713,12 +1715,14 @@ export const applicantRouter = router({
})).map((prs) => prs.roundId)
)
if (projectRoundIds.size === 0) return []
const evalRounds = await ctx.prisma.round.findMany({
where: {
competition: { programId: project.programId },
roundType: 'EVALUATION',
status: { in: ['ROUND_CLOSED', 'ROUND_ARCHIVED'] },
...(projectRoundIds.size > 0 ? { id: { in: [...projectRoundIds] } } : {}),
id: { in: [...projectRoundIds] },
},
select: {
id: true,
@@ -1828,15 +1832,12 @@ export const applicantRouter = router({
})
// Filter by award track membership
const projectRoundIds = new Set(
(await ctx.prisma.projectRoundState.findMany({
where: { projectId: project.id },
select: { roundId: true },
})).map((prs) => prs.roundId)
)
const isInAwardTrack = rounds.some(
(r) => r.specialAwardId && projectRoundIds.has(r.id)
)
const projectStates = await ctx.prisma.projectRoundState.findMany({
where: { projectId: project.id },
select: { roundId: true, round: { select: { specialAwardId: true } } },
})
const projectRoundIds = new Set(projectStates.map((prs) => prs.roundId))
const isInAwardTrack = projectStates.some((prs) => prs.round.specialAwardId)
return rounds
.filter((r) => {