Skip to content

Commit 26c3abd

Browse files
committed
fix: all workflow run to be created only on submissions which are in review or submission phase
1 parent ac74e6a commit 26c3abd

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/api/ai-workflow/ai-workflow.service.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -406,21 +406,18 @@ export class AiWorkflowService {
406406
);
407407
}
408408

409-
const aiWorkflowAllowedPhases = [
410-
'Submission',
411-
'Review',
412-
'Iterative Review',
413-
];
414-
const isNotInSubmissionOrReviewPhases = challenge.phases
415-
?.filter((item) => item.isOpen)
416-
.some((item) => aiWorkflowAllowedPhases.includes(item.name));
417-
if (
418-
challenge.status !== ChallengeStatus.COMPLETED &&
419-
isNotInSubmissionOrReviewPhases
420-
) {
421-
throw new InternalServerErrorException(
422-
`Challenge is either not completed or its not in one of these phases ${aiWorkflowAllowedPhases.join(',')}`,
423-
);
409+
const allowedPhases = ['Submission', 'Review', 'Iterative Review'];
410+
const phases = challenge.phases || [];
411+
const isInAllowedPhase = phases.some(
412+
(phase) => allowedPhases.includes(phase.name) && phase.isOpen,
413+
);
414+
415+
if (!isInAllowedPhase) {
416+
if (challenge.status !== 'COMPLETED') {
417+
throw new InternalServerErrorException(
418+
`Challenge ${submission.challengeId} is not in an allowed phase and is not completed.`,
419+
);
420+
}
424421
}
425422

426423
return await this.prisma.aiWorkflowRun.create({

0 commit comments

Comments
 (0)