File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -406,21 +406,18 @@ export class AiWorkflowService {
406
406
) ;
407
407
}
408
408
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
+ }
424
421
}
425
422
426
423
return await this . prisma . aiWorkflowRun . create ( {
You can’t perform that action at this time.
0 commit comments