@@ -404,10 +404,7 @@ export class ApplicationsService {
404404 const allApplicationsDto = await Promise . all (
405405 applications . map ( async ( app ) => {
406406 const ratings = this . calculateAllRatings ( app . reviews ) ;
407- const stageProgress = this . determineStageProgress (
408- app . stage ,
409- app . reviews ,
410- ) ;
407+ const stageProgress = this . determineStageProgress ( app , app . reviews ) ;
411408 const assignedRecruiters =
412409 await this . getAssignedRecruitersForApplication ( app ) ;
413410
@@ -493,10 +490,14 @@ export class ApplicationsService {
493490 * A stage is considered COMPLETED if it has been reviewed
494491 * Terminal stages (ACCEPTED/REJECTED) are always COMPLETED
495492 */
496- private determineStageProgress (
497- stage : ApplicationStage ,
498- reviews : any [ ] ,
499- ) : StageProgress {
493+ /**
494+ * A stage is considered COMPLETED only when all assigned recruiters have
495+ * submitted a review for that stage. If no recruiters are assigned, the
496+ * stage remains PENDING even if admins or others submit reviews.
497+ */
498+ private determineStageProgress ( app : Application , reviews : any [ ] ) : StageProgress {
499+ const stage = app . stage ;
500+
500501 // Terminal stages are always completed
501502 if (
502503 stage === ApplicationStage . ACCEPTED ||
@@ -505,9 +506,26 @@ export class ApplicationsService {
505506 return StageProgress . COMPLETED ;
506507 }
507508
508- // Check if current stage has been reviewed
509- const stageReviewed = reviews . some ( ( review ) => review . stage === stage ) ;
510- return stageReviewed ? StageProgress . COMPLETED : StageProgress . PENDING ;
509+ const assignedRecruiterIds = app . assignedRecruiterIds || [ ] ;
510+
511+ // If there are no assigned recruiters, the stage should not progress
512+ if ( assignedRecruiterIds . length === 0 ) {
513+ return StageProgress . PENDING ;
514+ }
515+
516+ // Collect reviewer IDs who have submitted a review for the current stage
517+ const reviewerIdsForStage = new Set (
518+ reviews
519+ . filter ( ( review ) => review . stage === stage )
520+ . map ( ( review ) => review . reviewerId ) ,
521+ ) ;
522+
523+ // Check that every assigned recruiter has submitted a review for this stage
524+ const allAssignedReviewed = assignedRecruiterIds . every ( ( id ) =>
525+ reviewerIdsForStage . has ( id ) ,
526+ ) ;
527+
528+ return allAssignedReviewed ? StageProgress . COMPLETED : StageProgress . PENDING ;
511529 }
512530
513531 /**
0 commit comments