Retroactive auto-PASS for projects with complete documents
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m14s
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m14s
Wire batchCheckRequirementsAndTransition into round activation and reopen so pre-existing projects that already have all required docs get auto- passed. Also adds checkDocumentCompletion endpoint for manual sweeps on already-active rounds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,24 @@ export async function activateRound(
|
||||
detailsJson: { name: round.name, roundType: round.roundType },
|
||||
})
|
||||
|
||||
// Retroactive check: auto-PASS any projects that already have all required docs uploaded
|
||||
// Non-fatal — runs after activation so it never blocks the transition
|
||||
try {
|
||||
const projectStates = await prisma.projectRoundState.findMany({
|
||||
where: { roundId, state: { in: ['PENDING', 'IN_PROGRESS'] } },
|
||||
select: { projectId: true },
|
||||
})
|
||||
if (projectStates.length > 0) {
|
||||
const projectIds = projectStates.map((ps: { projectId: string }) => ps.projectId)
|
||||
const result = await batchCheckRequirementsAndTransition(roundId, projectIds, actorId, prisma)
|
||||
if (result.transitionedCount > 0) {
|
||||
console.log(`[RoundEngine] On activation: auto-passed ${result.transitionedCount} projects with complete documents`)
|
||||
}
|
||||
}
|
||||
} catch (retroError) {
|
||||
console.error('[RoundEngine] Retroactive document check failed (non-fatal):', retroError)
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
round: { id: updated.id, status: updated.status },
|
||||
@@ -429,6 +447,23 @@ export async function reopenRound(
|
||||
},
|
||||
})
|
||||
|
||||
// Retroactive check: auto-PASS any projects that already have all required docs
|
||||
try {
|
||||
const projectStates = await prisma.projectRoundState.findMany({
|
||||
where: { roundId, state: { in: ['PENDING', 'IN_PROGRESS'] } },
|
||||
select: { projectId: true },
|
||||
})
|
||||
if (projectStates.length > 0) {
|
||||
const projectIds = projectStates.map((ps: { projectId: string }) => ps.projectId)
|
||||
const batchResult = await batchCheckRequirementsAndTransition(roundId, projectIds, actorId, prisma)
|
||||
if (batchResult.transitionedCount > 0) {
|
||||
console.log(`[RoundEngine] On reopen: auto-passed ${batchResult.transitionedCount} projects with complete documents`)
|
||||
}
|
||||
}
|
||||
} catch (retroError) {
|
||||
console.error('[RoundEngine] Retroactive document check on reopen failed (non-fatal):', retroError)
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
round: { id: result.updated.id, status: result.updated.status },
|
||||
|
||||
Reference in New Issue
Block a user