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