diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index c480400e57..8e756bf899 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -926,21 +926,7 @@ public function requestRemainingRunsWholeContestAction(int $contestId): Redirect if (!$contest) { throw new NotFoundHttpException(sprintf('Contest with ID %s not found', $contestId)); } - $judgings = $this->em->createQueryBuilder() - ->from(Judging::class, 'j') - ->select('j') - ->join('j.submission', 's') - ->join('s.team', 't') - ->join('t.category', 'tc') - ->andWhere('tc.visible = true') - ->andWhere('j.valid = true') - ->andWhere('j.result != :compiler_error') - ->andWhere('s.contest = :contestId') - ->setParameter('compiler_error', 'compiler-error') - ->setParameter('contestId', $contestId) - ->getQuery() - ->getResult(); - $this->judgeRemaining($judgings); + $this->judgeRemaining(contestId: $contestId); return $this->redirectToRoute('jury_contest', ['contestId' => $contestId]); } @@ -958,21 +944,7 @@ public function requestRemainingRunsContestProblemAction(int $contestId, int $pr ); } - $judgings = $this->em->createQueryBuilder() - ->from(Judging::class, 'j') - ->select('j') - ->join('j.submission', 's') - ->join('s.team', 't') - ->andWhere('s.problem = :problemId') - ->andWhere('j.valid = true') - ->andWhere('j.result != :compiler_error') - ->andWhere('s.contest = :contestId') - ->setParameter('problemId', $probId) - ->setParameter('contestId', $contestId) - ->setParameter('compiler_error', 'compiler-error') - ->getQuery() - ->getResult(); - $this->judgeRemaining($judgings); + $this->judgeRemaining(contestId: $contestId, probId: $probId); return $this->redirectToRoute('jury_contest', ['contestId' => $contestId]); } diff --git a/webapp/src/Controller/Jury/JudgeRemainingTrait.php b/webapp/src/Controller/Jury/JudgeRemainingTrait.php index 7358f7bc5e..466a652e26 100644 --- a/webapp/src/Controller/Jury/JudgeRemainingTrait.php +++ b/webapp/src/Controller/Jury/JudgeRemainingTrait.php @@ -11,7 +11,7 @@ trait JudgeRemainingTrait /** * @param Judging[] $judgings */ - protected function judgeRemaining(array $judgings): void + protected function judgeRemainingJudgings(array $judgings): void { $inProgress = []; $alreadyRequested = []; @@ -72,4 +72,39 @@ protected function judgeRemaining(array $judgings): void $this->addFlash('info', "Requested $numRequested remaining runs to be judged."); } } + + public function judgeRemaining(int $contestId = -1, string $categoryId = '', string|int $probId = '', string $langId = ''): void + { + $query = $this->em->createQueryBuilder() + ->from(Judging::class, 'j') + ->select('j') + ->join('j.submission', 's') + ->join('s.team', 't') + ->join('t.category', 'tc') + ->andWhere('j.valid = true') + ->andWhere('j.result != :compiler_error') + ->setParameter('compiler_error', 'compiler-error'); + if ($contestId > -1) { + $query + ->andWhere('s.contest = :contestId') + ->setParameter('contestId', $contestId); + } + if ($categoryId > -1) { + $query + ->andWhere('tc.categoryid = :categoryId') + ->setParameter('categoryId', $categoryId); + } + if ($probId !== '') { + $query + ->andWhere('s.problem = :probId') + ->setParameter('probId', $probId); + } + if ($langId !== '') { + $query + ->andWhere('s.language = :langId') + ->setParameter('langId', $langId); + } + $judgings = $query->getQuery()->getResult(); + $this->judgeRemainingJudgings($judgings); + } } diff --git a/webapp/src/Controller/Jury/LanguageController.php b/webapp/src/Controller/Jury/LanguageController.php index f9a2412a48..76e69be252 100644 --- a/webapp/src/Controller/Jury/LanguageController.php +++ b/webapp/src/Controller/Jury/LanguageController.php @@ -334,23 +334,7 @@ public function requestRemainingRunsWholeLanguageAction(string $langId): Redirec throw new NotFoundHttpException(sprintf('Language with ID %s not found', $langId)); } $contestId = $this->dj->getCurrentContest()->getCid(); - $query = $this->em->createQueryBuilder() - ->from(Judging::class, 'j') - ->select('j') - ->join('j.submission', 's') - ->join('s.team', 't') - ->andWhere('j.valid = true') - ->andWhere('j.result != :compiler_error') - ->andWhere('s.language = :langId') - ->setParameter('compiler_error', 'compiler-error') - ->setParameter('langId', $langId); - if ($contestId > -1) { - $query->andWhere('s.contest = :contestId') - ->setParameter('contestId', $contestId); - } - $judgings = $query->getQuery() - ->getResult(); - $this->judgeRemaining($judgings); + $this->judgeRemaining(contestId: $contestId, langId: $langId); return $this->redirectToRoute('jury_language', ['langId' => $langId]); } } diff --git a/webapp/src/Controller/Jury/ProblemController.php b/webapp/src/Controller/Jury/ProblemController.php index 0542ae5943..28e9916724 100644 --- a/webapp/src/Controller/Jury/ProblemController.php +++ b/webapp/src/Controller/Jury/ProblemController.php @@ -1156,23 +1156,7 @@ public function requestRemainingRunsWholeProblemAction(string $probId): Redirect throw new NotFoundHttpException(sprintf('Problem with ID %s not found', $probId)); } $contestId = $this->dj->getCurrentContest()->getCid(); - $query = $this->em->createQueryBuilder() - ->from(Judging::class, 'j') - ->select('j') - ->join('j.submission', 's') - ->join('s.team', 't') - ->andWhere('j.valid = true') - ->andWhere('j.result != :compiler_error') - ->andWhere('s.problem = :probId') - ->setParameter('compiler_error', 'compiler-error') - ->setParameter('probId', $probId); - if ($contestId > -1) { - $query->andWhere('s.contest = :contestId') - ->setParameter('contestId', $contestId); - } - $judgings = $query->getQuery() - ->getResult(); - $this->judgeRemaining($judgings); + $this->judgeRemaining(contestId: $contestId, probId: $probId); return $this->redirectToRoute('jury_problem', ['probId' => $probId]); } diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php index ee0fb74dbf..b8cf48f021 100644 --- a/webapp/src/Controller/Jury/SubmissionController.php +++ b/webapp/src/Controller/Jury/SubmissionController.php @@ -1053,7 +1053,7 @@ public function requestRemainingRuns(Request $request, int $judgingId): Redirect if ($judging === null) { throw new BadRequestHttpException("Unknown judging with '$judgingId' requested."); } - $this->judgeRemaining([$judging]); + $this->judgeRemainingJudgings([$judging]); return $this->redirectToLocalReferrer($this->router, $request, $this->generateUrl('jury_submission_by_judging', ['jid' => $judgingId]) diff --git a/webapp/src/Controller/Jury/TeamCategoryController.php b/webapp/src/Controller/Jury/TeamCategoryController.php index 4a8205b5a1..dc56442b4a 100644 --- a/webapp/src/Controller/Jury/TeamCategoryController.php +++ b/webapp/src/Controller/Jury/TeamCategoryController.php @@ -238,24 +238,7 @@ public function requestRemainingRunsWholeTeamCategoryAction(string $categoryId): throw new NotFoundHttpException(sprintf('Team category with ID %s not found', $categoryId)); } $contestId = $this->dj->getCurrentContest()->getCid(); - $query = $this->em->createQueryBuilder() - ->from(Judging::class, 'j') - ->select('j') - ->join('j.submission', 's') - ->join('s.team', 't') - ->join('t.category', 'tc') - ->andWhere('j.valid = true') - ->andWhere('j.result != :compiler_error') - ->andWhere('tc.categoryid = :categoryId') - ->setParameter('compiler_error', 'compiler-error') - ->setParameter('categoryId', $categoryId); - if ($contestId > -1) { - $query->andWhere('s.contest = :contestId') - ->setParameter('contestId', $contestId); - } - $judgings = $query->getQuery() - ->getResult(); - $this->judgeRemaining($judgings); + $this->judgeRemaining(contestId: $contestId, categoryId: $categoryId); return $this->redirectToRoute('jury_team_category', ['categoryId' => $categoryId]); } }