From 3ebae947eae3b6da60bc925d623cfaeda44bac76 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Fri, 13 Aug 2021 21:02:19 +0200 Subject: [PATCH 1/5] Remove JudgehostRestriction feature --- ChangeLog | 1 + .../Controller/API/JudgehostController.php | 22 -- .../Controller/Jury/AuditLogController.php | 2 - .../src/Controller/Jury/ContestController.php | 13 - .../Controller/Jury/JudgehostController.php | 13 +- .../Jury/JudgehostRestrictionController.php | 259 ------------------ .../Controller/Jury/SubmissionController.php | 26 +- .../Test/AddJudgehostRestrictionFixture.php | 21 -- webapp/src/Entity/Judgehost.php | 19 -- webapp/src/Entity/JudgehostRestriction.php | 142 ---------- .../Form/Type/JudgehostRestrictionType.php | 82 ------ webapp/src/Form/Type/JudgehostType.php | 8 - webapp/src/Service/CheckConfigService.php | 52 ---- webapp/templates/jury/index.html.twig | 1 - webapp/templates/jury/judgehost.html.twig | 12 - .../jury/judgehost_restriction.html.twig | 120 -------- .../jury/judgehost_restriction_add.html.twig | 18 -- .../jury/judgehost_restriction_edit.html.twig | 18 -- .../jury/judgehost_restrictions.html.twig | 23 -- .../jury/partials/judgehosts_form.html.twig | 5 - .../JudgehostRestrictionsControllerTest.php | 36 --- 21 files changed, 5 insertions(+), 888 deletions(-) delete mode 100644 webapp/src/Controller/Jury/JudgehostRestrictionController.php delete mode 100644 webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php delete mode 100644 webapp/src/Entity/JudgehostRestriction.php delete mode 100644 webapp/src/Form/Type/JudgehostRestrictionType.php delete mode 100644 webapp/templates/jury/judgehost_restriction.html.twig delete mode 100644 webapp/templates/jury/judgehost_restriction_add.html.twig delete mode 100644 webapp/templates/jury/judgehost_restriction_edit.html.twig delete mode 100644 webapp/templates/jury/judgehost_restrictions.html.twig delete mode 100644 webapp/tests/Unit/Controller/Jury/JudgehostRestrictionsControllerTest.php diff --git a/ChangeLog b/ChangeLog index 5460a95a98..b33b02d59e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ Version 8.0.0 - DEV - Improve API action to add submission to adhere to the CCS spec. - Add API action to create clarification following CCS spec. - Add support for showing (pending) awards on the scoreboard. Thanks @shuibinlong! + - Remove JudgehostRestriction feature due to new Judgehost API Version 7.3.2 - 23 November 2020 diff --git a/webapp/src/Controller/API/JudgehostController.php b/webapp/src/Controller/API/JudgehostController.php index 14a2d2b312..5ed3ea3540 100644 --- a/webapp/src/Controller/API/JudgehostController.php +++ b/webapp/src/Controller/API/JudgehostController.php @@ -1137,28 +1137,6 @@ private function getSubmissionsToJudge(Judgehost $judgehost, $restrictJudgingOnS ->addOrderBy('s.submittime', 'ASC') ->addOrderBy('s.submitid', 'ASC'); - // Apply restrictions - if ($judgehost->getRestriction()) { - $restrictions = $judgehost->getRestriction()->getRestrictions(); - - if (isset($restrictions['contest'])) { - $queryBuilder - ->andWhere('s.contest IN (:restrictionContestIds)') - ->setParameter(':restrictionContestIds', $restrictions['contest']); - } - - if (isset($restrictions['problem'])) { - $queryBuilder - ->andWhere('s.problem IN (:restrictionProblemIds)') - ->setParameter(':restrictionProblemIds', $restrictions['problem']); - } - - if (isset($restrictions['language'])) { - $queryBuilder - ->andWhere('s.language IN (:restrictionLanguageIds)') - ->setParameter(':restrictionLanguageIds', $restrictions['language']); - } - } if ($restrictJudgingOnSameJudgehost) { $queryBuilder ->leftJoin('s.judgings', 'j', Join::WITH, 'j.judgehost = :judgehost') diff --git a/webapp/src/Controller/Jury/AuditLogController.php b/webapp/src/Controller/Jury/AuditLogController.php index c13d2b8f33..f32f3bbae9 100644 --- a/webapp/src/Controller/Jury/AuditLogController.php +++ b/webapp/src/Controller/Jury/AuditLogController.php @@ -161,8 +161,6 @@ private function generateDatatypeUrl(string $type, $id): ?string return $this->generateUrl('jury_judgehosts'); case 'judgehosts': return $this->generateUrl('jury_judgehosts'); - case 'judgehost_restriction': - return $this->generateUrl('jury_judgehost_restriction', ['restrictionId' => $id]); case 'judging': return $this->generateUrl('jury_submission_by_judging', ['jid' => $id]); case 'external_judgement': diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index 35bc1590cc..11d767d147 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -675,7 +675,6 @@ public function prefetchAction(Request $request, int $contestId) $cnt = 0; foreach ($judgehosts as $judgehost) { /** @var Judgehost $judgehost */ - $judgehostRestriction = $judgehost->getRestriction(); foreach ($contest->getProblems() as $contestProblem) { /** @var ContestProblem $contestProblem */ if (!$contestProblem->getAllowJudge() || !$contestProblem->getAllowSubmit()) { @@ -683,12 +682,6 @@ public function prefetchAction(Request $request, int $contestId) } /** @var Problem $problem */ $problem = $contestProblem->getProblem(); - if ($judgehostRestriction !== null) { - $restrictedProblems = $judgehostRestriction->getProblems(); - if (!empty($restrictedProblems) && !in_array($problem->getProbid(), $restrictedProblems)) { - continue; - } - } foreach ($problem->getTestcases() as $testcase) { /** @var Testcase $testcase */ $judgeTask = new JudgeTask(); @@ -723,12 +716,6 @@ public function prefetchAction(Request $request, int $contestId) ); foreach ($languages as $language) { /** @var Language $language */ - if ($judgehostRestriction !== null) { - $restrictedLangs = $judgehostRestriction->getLanguages(); - if (!empty($restrictedLangs) && !in_array($language->getLangid(), $restrictedLangs)) { - continue; - } - } $compileExec = $language->getCompileExecutable()->getImmutableExecutable(); $judgeTask = new JudgeTask(); $judgeTask diff --git a/webapp/src/Controller/Jury/JudgehostController.php b/webapp/src/Controller/Jury/JudgehostController.php index 475bf06bab..86e8b083ad 100644 --- a/webapp/src/Controller/Jury/JudgehostController.php +++ b/webapp/src/Controller/Jury/JudgehostController.php @@ -81,8 +81,7 @@ public function indexAction(Request $request): Response /** @var Judgehost[] $judgehosts */ $judgehosts = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.hidden = 0') ->orderBy('j.hostname') ->getQuery()->getResult(); @@ -92,7 +91,6 @@ public function indexAction(Request $request): Response 'hostname' => ['title' => 'hostname'], 'active' => ['title' => 'active'], 'status' => ['title' => 'status'], - 'restriction' => ['title' => 'restriction'], 'load' => ['title' => 'load'], 'last_judgingid' => ['title' => 'last judging'], ]; @@ -207,9 +205,6 @@ public function indexAction(Request $request): Response 'active' => [ 'value' => $judgehost->getActive() ? 'yes' : 'no', ], - 'restriction' => [ - 'value' => $judgehost->getRestriction() ? $judgehost->getRestriction()->getName() : 'none', - ], ]); // Create action links @@ -275,8 +270,7 @@ public function viewAction(Request $request, int $judgehostid): Response /** @var Judgehost $judgehost */ $judgehost = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.judgehostid = :judgehostid') ->setParameter(':judgehostid', $judgehostid) ->getQuery() @@ -341,8 +335,7 @@ public function deleteAction(Request $request, int $judgehostid): Response /** @var Judgehost $judgehost */ $judgehost = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.judgehostid = :judgehostid') ->setParameter(':judgehostid', $judgehostid) ->getQuery() diff --git a/webapp/src/Controller/Jury/JudgehostRestrictionController.php b/webapp/src/Controller/Jury/JudgehostRestrictionController.php deleted file mode 100644 index e9b4b34796..0000000000 --- a/webapp/src/Controller/Jury/JudgehostRestrictionController.php +++ /dev/null @@ -1,259 +0,0 @@ -em = $entityManager; - $this->dj = $dj; - $this->eventLog = $eventLog; - $this->kernel = $kernel; - } - - /** - * @Route("", name="jury_judgehost_restrictions") - */ - public function indexAction(Request $request): Response - { - /** @var JudgehostRestriction[] $judgehostRestrictions */ - $judgehostRestrictions = $this->em->createQueryBuilder() - ->from(JudgehostRestriction::class, 'jr') - ->select('jr') - ->orderBy('jr.restrictionid') - ->getQuery()->getResult(); - - $table_fields = [ - 'restrictionid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true], - 'name' => ['title' => 'name', 'sort' => true], - 'numcontests' => ['title' => '# contests', 'sort' => true], - 'numproblems' => ['title' => '# problems', 'sort' => true], - 'numlanguages' => ['title' => '# languages', 'sort' => true], - 'numlinkedjudgehosts' => ['title' => '# linked judgehosts', 'sort' => true], - ]; - - $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $judgehost_restrictions_table = []; - foreach ($judgehostRestrictions as $judgehostRestriction) { - $judgehostrestrictiondata = []; - $judgehostrestrictionactions = []; - // Get whatever fields we can from the problem object itself - foreach ($table_fields as $k => $v) { - if ($propertyAccessor->isReadable($judgehostRestriction, $k)) { - $judgehostrestrictiondata[$k] = ['value' => $propertyAccessor->getValue($judgehostRestriction, $k)]; - } - } - - $judgehostrestrictiondata = array_merge($judgehostrestrictiondata, [ - 'numcontests' => ['value' => count($judgehostRestriction->getContests())], - 'numproblems' => ['value' => count($judgehostRestriction->getProblems())], - 'numlanguages' => ['value' => count($judgehostRestriction->getLanguages())], - 'numlinkedjudgehosts' => ['value' => $judgehostRestriction->getJudgehosts()->count()], - ]); - - // Create action links - if ($this->isGranted('ROLE_ADMIN')) { - $judgehostrestrictionactions[] = [ - 'icon' => 'edit', - 'title' => 'edit this judgehost restriction', - 'link' => $this->generateUrl('jury_judgehost_restriction_edit', [ - 'restrictionId' => $judgehostRestriction->getRestrictionid(), - ]) - ]; - $judgehostrestrictionactions[] = [ - 'icon' => 'trash-alt', - 'title' => 'delete this judgehost restriction', - 'link' => $this->generateUrl('jury_judgehost_restriction_delete', [ - 'restrictionId' => $judgehostRestriction->getRestrictionid(), - ]), - 'ajaxModal' => true, - ]; - } - - // Save this to our list of rows - $judgehost_restrictions_table[] = [ - 'data' => $judgehostrestrictiondata, - 'actions' => $judgehostrestrictionactions, - 'link' => $this->generateUrl('jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()]), - ]; - } - - - return $this->render('jury/judgehost_restrictions.html.twig', [ - 'judgehost_restrictions' => $judgehost_restrictions_table, - 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, - ]); - } - - /** - * @Route("/{restrictionId<\d+>}", name="jury_judgehost_restriction") - * @throws NonUniqueResultException - */ - public function viewAction(int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->createQueryBuilder() - ->from(JudgehostRestriction::class, 'jr') - ->leftJoin('jr.judgehosts', 'j') - ->select('jr', 'j') - ->andWhere('jr.restrictionid = :restrictionId') - ->setParameter(':restrictionId', $restrictionId) - ->getQuery() - ->getOneOrNullResult(); - if (!$judgehostRestriction) { - throw new NotFoundHttpException(sprintf('Judgehost restriction with ID %s not found', $restrictionId)); - } - - /** @var Contest[] $contests */ - $contests = $this->em->createQueryBuilder() - ->from(Contest::class, 'c', 'c.cid') - ->select('c') - ->getQuery() - ->getResult(); - - /** @var Problem[] $problems */ - $problems = $this->em->createQueryBuilder() - ->from(Problem::class, 'p', 'p.probid') - ->select('p') - ->getQuery() - ->getResult(); - - /** @var Language[] $languages */ - $languages = $this->em->createQueryBuilder() - ->from(Language::class, 'l', 'l.langid') - ->select('l') - ->getQuery() - ->getResult(); - - return $this->render('jury/judgehost_restriction.html.twig', [ - 'judgehostRestriction' => $judgehostRestriction, - 'contests' => $contests, - 'problems' => $problems, - 'languages' => $languages, - ]); - } - - /** - * @Route("/{restrictionId<\d+>}/edit", name="jury_judgehost_restriction_edit") - * @IsGranted("ROLE_ADMIN") - */ - public function editAction(Request $request, int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->getRepository(JudgehostRestriction::class)->find($restrictionId); - - $form = $this->createForm(JudgehostRestrictionType::class, $judgehostRestriction); - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->em->flush(); - $this->dj->auditlog('judgehost_restriction', $judgehostRestriction->getRestrictionid(), - 'updated'); - return $this->redirect($this->generateUrl( - 'jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()] - )); - } - - return $this->render('jury/judgehost_restriction_edit.html.twig', [ - 'judgehostRestriction' => $judgehostRestriction, - 'form' => $form->createView(), - ]); - } - - /** - * @Route("/{restrictionId<\d+>}/delete", name="jury_judgehost_restriction_delete") - * @IsGranted("ROLE_ADMIN") - * @throws DBALException - * @throws NoResultException - * @throws NonUniqueResultException - */ - public function deleteAction(Request $request, int $restrictionId): Response - { - /** @var JudgehostRestriction $judgehostRestriction */ - $judgehostRestriction = $this->em->getRepository(JudgehostRestriction::class)->find($restrictionId); - - return $this->deleteEntities($request, $this->em, $this->dj, $this->eventLog, $this->kernel, - [$judgehostRestriction], $this->generateUrl('jury_judgehost_restrictions')); - } - - /** - * @Route("/add", name="jury_judgehost_restriction_add") - * @IsGranted("ROLE_ADMIN") - */ - public function addAction(Request $request): Response - { - $judgehostRestriction = new JudgehostRestriction(); - - $form = $this->createForm(JudgehostRestrictionType::class, $judgehostRestriction); - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->em->persist($judgehostRestriction); - $this->em->flush(); - $this->dj->auditlog('judgehost_restriction', $judgehostRestriction->getRestrictionid(), - 'added'); - return $this->redirect($this->generateUrl( - 'jury_judgehost_restriction', - ['restrictionId' => $judgehostRestriction->getRestrictionid()] - )); - } - - return $this->render('jury/judgehost_restriction_add.html.twig', [ - 'form' => $form->createView(), - ]); - } -} diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php index 76982ef097..7052c1478e 100644 --- a/webapp/src/Controller/Jury/SubmissionController.php +++ b/webapp/src/Controller/Jury/SubmissionController.php @@ -324,18 +324,12 @@ public function viewAction(Request $request, int $submitId) /** @var Judgehost[] $judgehosts */ $judgehosts = $this->em->createQueryBuilder() ->from(Judgehost::class, 'j') - ->leftJoin('j.restriction', 'r') - ->select('j', 'r') + ->select('j') ->andWhere('j.active = 1') ->getQuery() ->getResult(); $canBeJudged = false; foreach ($judgehosts as $judgehost) { - if (!$judgehost->getRestriction()) { - $canBeJudged = true; - break; - } - $queryBuilder = $this->em->createQueryBuilder() ->from(Submission::class, 's') ->select('s') @@ -349,24 +343,6 @@ public function viewAction(Request $request, int $submitId) ->setParameter(':submitid', $submission->getSubmitid()) ->setMaxResults(1); - $restrictions = $judgehost->getRestriction()->getRestrictions(); - if (isset($restrictions['contest'])) { - $queryBuilder - ->andWhere('s.contest IN (:contests)') - ->setParameter(':contests', $restrictions['contest']); - } - if (isset($restrictions['problem'])) { - $queryBuilder - ->leftJoin('s.problem', 'p') - ->andWhere('p.probid IN (:problems)') - ->setParameter(':problems', $restrictions['problem']); - } - if (isset($restrictions['language'])) { - $queryBuilder - ->andWhere('s.language IN (:languages)') - ->setParameter(':languages', $restrictions['language']); - } - if ($queryBuilder->getQuery()->getOneOrNullResult()) { $canBeJudged = true; } diff --git a/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php b/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php deleted file mode 100644 index d1eae5ef27..0000000000 --- a/webapp/src/DataFixtures/Test/AddJudgehostRestrictionFixture.php +++ /dev/null @@ -1,21 +0,0 @@ -getRepository(Problem::class)->findOneBy(['externalid' => 'boolfind']); - $restriction = (new JudgehostRestriction()) - ->setName('TestRestriction') - ->setProblems([$problem]) - ->setRejudgeOwn(True); - $manager->persist($restriction); - $manager->flush(); - } -} diff --git a/webapp/src/Entity/Judgehost.php b/webapp/src/Entity/Judgehost.php index 955aee8b93..2a6f599f35 100644 --- a/webapp/src/Entity/Judgehost.php +++ b/webapp/src/Entity/Judgehost.php @@ -14,7 +14,6 @@ * @ORM\Table( * name="judgehost", * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4", "comment"="Hostnames of the autojudgers"}, - * indexes={@ORM\Index(name="restrictionid", columns={"restrictionid"})}, * uniqueConstraints={ * @ORM\UniqueConstraint(name="hostname", columns={"hostname"}) * }) @@ -58,13 +57,6 @@ class Judgehost */ private $polltime; - /** - * @ORM\ManyToOne(targetEntity="JudgehostRestriction", inversedBy="judgehosts") - * @ORM\JoinColumn(name="restrictionid", referencedColumnName="restrictionid", onDelete="SET NULL") - * @Serializer\Exclude() - */ - private $restriction; - /** * @ORM\OneToMany(targetEntity="Judging", mappedBy="judgehost") * @Serializer\Exclude() @@ -137,17 +129,6 @@ public function getPolltime() return $this->polltime; } - public function setRestriction(?JudgehostRestriction $restriction = null): Judgehost - { - $this->restriction = $restriction; - return $this; - } - - public function getRestriction(): ?JudgehostRestriction - { - return $this->restriction; - } - public function addJudging(Judging $judging): Judgehost { $this->judgings[] = $judging; diff --git a/webapp/src/Entity/JudgehostRestriction.php b/webapp/src/Entity/JudgehostRestriction.php deleted file mode 100644 index 99bf0b1020..0000000000 --- a/webapp/src/Entity/JudgehostRestriction.php +++ /dev/null @@ -1,142 +0,0 @@ -judgehosts = new ArrayCollection(); - } - - public function getRestrictionid(): int - { - return $this->restrictionid; - } - - public function setName(string $name): JudgehostRestriction - { - $this->name = $name; - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function getShortDescription(): string - { - return $this->getName(); - } - - public function setRestrictions(array $restrictions): JudgehostRestriction - { - $this->restrictions = $restrictions; - return $this; - } - - public function getRestrictions(): array - { - return $this->restrictions; - } - - public function setContests(array $contests): JudgehostRestriction - { - $this->restrictions['contest'] = $contests; - return $this; - } - - public function getContests(): array - { - return $this->restrictions['contest'] ?? []; - } - - public function setProblems(array $problems): JudgehostRestriction - { - $this->restrictions['problem'] = $problems; - return $this; - } - - public function getProblems(): array - { - return $this->restrictions['problem'] ?? []; - } - - public function setLanguages(array $languages): JudgehostRestriction - { - $this->restrictions['language'] = $languages; - return $this; - } - - public function getLanguages(): array - { - return $this->restrictions['language'] ?? []; - } - - public function setRejudgeOwn(bool $rejudgeOwn): JudgehostRestriction - { - $this->restrictions['rejudge_own'] = $rejudgeOwn; - return $this; - } - - public function getRejudgeOwn(): bool - { - return $this->restrictions['rejudge_own'] ?? true; - } - - public function addJudgehost(Judgehost $judgehost): JudgehostRestriction - { - $this->judgehosts[] = $judgehost; - return $this; - } - - public function removeJudgehost(Judgehost $judgehost) - { - $this->judgehosts->removeElement($judgehost); - } - - public function getJudgehosts(): Collection - { - return $this->judgehosts; - } -} diff --git a/webapp/src/Form/Type/JudgehostRestrictionType.php b/webapp/src/Form/Type/JudgehostRestrictionType.php deleted file mode 100644 index 1620ce592e..0000000000 --- a/webapp/src/Form/Type/JudgehostRestrictionType.php +++ /dev/null @@ -1,82 +0,0 @@ -em = $em; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('name', TextType::class, [ - 'constraints' => [new NotBlank()], - ]); - - // Note that we can not use the normal EntityType form type, because these are not Doctrine associations - - $contests = $this->em->getRepository(Contest::class)->findAll(); - $contestChoices = []; - foreach ($contests as $contest) { - $contestChoices[$contest->getName()] = $contest->getCid(); - } - $builder->add('contests', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $contestChoices, - ]); - - $problems = $this->em->getRepository(Problem::class)->findAll(); - $problemChoices = []; - foreach ($problems as $problem) { - $problemChoices[$problem->getName()] = $problem->getProbid(); - } - $builder->add('problems', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $problemChoices, - ]); - - $languages = $this->em->getRepository(Language::class)->findAll(); - $languageChoices = []; - foreach ($languages as $language) { - $languageChoices[$language->getName()] = $language->getLangid(); - } - $builder->add('languages', ChoiceType::class, [ - 'multiple' => true, - 'required' => false, - 'choices' => $languageChoices, - ]); - $builder->add('rejudge_own', ChoiceType::class, [ - 'expanded' => true, - 'choices' => ['Yes' => true, 'Prefer a different judgehost (if possible)' => false], - 'label' => 'Allow rejudging on any judgehost', - ]); - $builder->add('save', SubmitType::class); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(['data_class' => JudgehostRestriction::class]); - } -} diff --git a/webapp/src/Form/Type/JudgehostType.php b/webapp/src/Form/Type/JudgehostType.php index 3af9b01c2b..c2a0e808a9 100644 --- a/webapp/src/Form/Type/JudgehostType.php +++ b/webapp/src/Form/Type/JudgehostType.php @@ -3,7 +3,6 @@ namespace App\Form\Type; use App\Entity\Judgehost; -use App\Entity\JudgehostRestriction; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -30,13 +29,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'no' => false, ], ]); - $builder->add('restriction', EntityType::class, [ - 'class' => JudgehostRestriction::class, - 'choice_label' => 'name', - 'required' => false, - 'placeholder' => '-- no restrictions --', - 'label' => 'Restrictions', - ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/webapp/src/Service/CheckConfigService.php b/webapp/src/Service/CheckConfigService.php index a35f6db238..86980f34f2 100644 --- a/webapp/src/Service/CheckConfigService.php +++ b/webapp/src/Service/CheckConfigService.php @@ -129,7 +129,6 @@ public function runAll() : array $pl = [ 'problems' => $this->checkProblemsValidate(), 'languages' => $this->checkLanguagesValidate(), - 'judgability' => $this->checkProblemLanguageJudgability(), ]; $results['Problems and languages'] = $pl; @@ -597,57 +596,6 @@ public function checkLanguagesValidate() : array ($desc ?: 'No languages with problems found.')]; } - public function checkProblemLanguageJudgability() : array - { - $judgehosts = $this->em->getRepository(Judgehost::class)->findBy(['active' => 1]); - - foreach ($judgehosts as $judgehost) { - if ($judgehost->getRestriction() === null) { - return ['caption' => 'Problem, language and contest judgability', - 'result' => 'O', - 'desc' => sprintf("At least one judgehost (%s) is active and unrestricted.", $judgehost->getHostname())]; - } - } - - $languages = $this->em->getRepository(Language::class)->findAll(); - $contests = $this->dj->getCurrentContests(null, true); - - $desc = ''; - $result = 'O'; - foreach ($contests as $contest) { - foreach ($contest->getProblems() as $cp ) { - foreach ($languages as $lang) { - if (!$lang->getAllowSubmit()) { - continue; - } - $found1 = false; - foreach ($judgehosts as $judgehost) { - $rest = $judgehost->getRestriction(); - $rest_c = $rest->getContests(); - $rest_p = $rest->getProblems(); - $rest_l = $rest->getLanguages(); - if ((empty($rest_c) || in_array($contest->getCid(), $rest_c)) && - (empty($rest_p) || in_array($cp->getProbid(), $rest_p)) && - (empty($rest_l) || in_array($lang->getLangid(), $rest_l))) { - $found1 = true; - continue; - } - } - if (!$found1) { - $result = 'E'; - $desc .= sprintf("No active judgehost that allows combination c%s-p%s-%s\n", - $contest->getCid(), $cp->getProbid(), $lang->getLangid()); - } - } - } - } - $desc = $desc ?: 'Found at least one judgehost for each combination of current/future contest, associated problem, enabled language'; - - return ['caption' => 'Problem, language and contest judgability', - 'result' => $result, - 'desc' => $desc]; - } - public function checkAffiliations() : array { $show_logos = $this->config->get('show_affiliation_logos'); diff --git a/webapp/templates/jury/index.html.twig b/webapp/templates/jury/index.html.twig index 81147cc9d9..aef7f3008a 100644 --- a/webapp/templates/jury/index.html.twig +++ b/webapp/templates/jury/index.html.twig @@ -29,7 +29,6 @@
  • Contests
  • Executables
  • Judgehosts
  • -
  • Judgehost Restrictions
  • Languages
  • Problems
  • Users
  • diff --git a/webapp/templates/jury/judgehost.html.twig b/webapp/templates/jury/judgehost.html.twig index db940c992c..bfa6fbe717 100644 --- a/webapp/templates/jury/judgehost.html.twig +++ b/webapp/templates/jury/judgehost.html.twig @@ -31,18 +31,6 @@ Active {{ judgehost.active | printYesNo }} - - Restriction - - {% if not judgehost.restriction %} - None - {% else %} - - {{ judgehost.restriction.name }} - - {% endif %} - - Status diff --git a/webapp/templates/jury/judgehost_restriction.html.twig b/webapp/templates/jury/judgehost_restriction.html.twig deleted file mode 100644 index 9f47464198..0000000000 --- a/webapp/templates/jury/judgehost_restriction.html.twig +++ /dev/null @@ -1,120 +0,0 @@ -{% extends "jury/base.html.twig" %} -{% import "jury/jury_macros.twig" as macros %} - -{% block title %}Judgehost restriction {{ judgehostRestriction.name }} - {{ parent() }}{% endblock %} - -{% block extrahead %} - {{ parent() }} - {{ macros.table_extrahead() }} -{% endblock %} - -{% block content %} - -

    Judgehost restriction {{ judgehostRestriction.name }}

    - -
    -
    - - - - - - - - - - - - {% if judgehostRestriction.contests is empty %} - - {% else %} - - {% endif %} - - - - {% if judgehostRestriction.problems is empty %} - - {% else %} - - {% endif %} - - - - {% if judgehostRestriction.languages is empty %} - - {% else %} - - {% endif %} - - - - - -
    ID{{ judgehostRestriction.restrictionid }}
    Name{{ judgehostRestriction.name }}
    Restrict to contestsnone - {% for contest in judgehostRestriction.contests %} - - {{ contests[contest].name }} ({{ contests[contest].shortname }} - c{{ contest }}) - -
    - {% endfor %} -
    Restrict to problemsnone - {% for problem in judgehostRestriction.problems %} - - {{ problems[problem].name }} (p{{ problem }}) - -
    - {% endfor %} -
    Restrict to languagesnone - {% for language in judgehostRestriction.languages %} - - {{ languages[language].name }} ({{ language }}) - -
    - {% endfor %} -
    Rejudge by same judgehost{{ judgehostRestriction.rejudgeOwn | printYesNo }}
    -
    -
    - -
    - {%- if is_granted('ROLE_ADMIN') -%} - {{ button(path('jury_judgehost_restriction_edit', {'restrictionId': judgehostRestriction.restrictionid}), 'Edit', 'primary', 'edit') }} - {{ button(path('jury_judgehost_restriction_delete', {'restrictionId': judgehostRestriction.restrictionid}), 'Delete', 'danger', 'trash-alt', true) }} - {% endif %} -
    - -

    Judgehosts having restriction {{ judgehostRestriction.name }}

    - {% if judgehostRestriction.judgehosts is empty %} -

    no judgehosts

    - {% else %} -
    -
    - - - - - - - - - {% for judgehost in judgehostRestriction.judgehosts %} - - - - - {% endfor %} - -
    hostnameactive
    - - {{ judgehost.hostname }} - - - - {{ judgehost.active | printYesNo }} - -
    -
    -
    - {% endif %} - -{% endblock %} diff --git a/webapp/templates/jury/judgehost_restriction_add.html.twig b/webapp/templates/jury/judgehost_restriction_add.html.twig deleted file mode 100644 index 1ab9b11c6f..0000000000 --- a/webapp/templates/jury/judgehost_restriction_add.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "jury/base.html.twig" %} -{% import "jury/jury_macros.twig" as macros %} - -{% block title %}Add judgehost restriction - {{ parent() }}{% endblock %} - -{% block extrahead %} - {{ parent() }} - {{ macros.table_extrahead() }} - {{ macros.select2_extrahead() }} -{% endblock %} - -{% block content %} - -

    Add judgehost restriction

    - - {{ form(form) }} - -{% endblock %} diff --git a/webapp/templates/jury/judgehost_restriction_edit.html.twig b/webapp/templates/jury/judgehost_restriction_edit.html.twig deleted file mode 100644 index f4fe4cd61a..0000000000 --- a/webapp/templates/jury/judgehost_restriction_edit.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "jury/base.html.twig" %} -{% import "jury/jury_macros.twig" as macros %} - -{% block title %}Edit judgehost restriction {{ judgehostRestriction.name }} - {{ parent() }}{% endblock %} - -{% block extrahead %} - {{ parent() }} - {{ macros.table_extrahead() }} - {{ macros.select2_extrahead() }} -{% endblock %} - -{% block content %} - -

    Edit judgehost restriction {{ judgehostRestriction.name }}

    - - {{ form(form) }} - -{% endblock %} diff --git a/webapp/templates/jury/judgehost_restrictions.html.twig b/webapp/templates/jury/judgehost_restrictions.html.twig deleted file mode 100644 index d1b9996f6a..0000000000 --- a/webapp/templates/jury/judgehost_restrictions.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "jury/base.html.twig" %} -{% import "jury/jury_macros.twig" as macros %} - -{% block title %}Judgehost restrictions - {{ parent() }}{% endblock %} - -{% block extrahead %} - {{ parent() }} - {{ macros.table_extrahead() }} -{% endblock %} - -{% block content %} - -

    Judgehost restrictions

    - - {{ macros.table(judgehost_restrictions, table_fields, num_actions) }} - - {%- if is_granted('ROLE_ADMIN') %} -

    - {{ button(path('jury_judgehost_restriction_add'), 'Add new judgehost restriction', 'primary', 'plus') }} -

    - {%- endif %} - -{% endblock %} diff --git a/webapp/templates/jury/partials/judgehosts_form.html.twig b/webapp/templates/jury/partials/judgehosts_form.html.twig index 6b53aaf11e..ed69c5400c 100644 --- a/webapp/templates/jury/partials/judgehosts_form.html.twig +++ b/webapp/templates/jury/partials/judgehosts_form.html.twig @@ -6,7 +6,6 @@ {{ form_label(form.judgehosts.vars.prototype.hostname) }} {{ form_label(form.judgehosts.vars.prototype.active) }} {{ form_label(form.judgehosts.vars.prototype.hidden) }} - {{ form_label(form.judgehosts.vars.prototype.restriction) }} @@ -23,10 +22,6 @@ {{ form_widget(judgehost.hidden) }} {{ form_errors(judgehost.hidden) }} - - {{ form_widget(judgehost.restriction) }} - {{ form_errors(judgehost.restriction) }} - {% endfor %} diff --git a/webapp/tests/Unit/Controller/Jury/JudgehostRestrictionsControllerTest.php b/webapp/tests/Unit/Controller/Jury/JudgehostRestrictionsControllerTest.php deleted file mode 100644 index c0cce8bfc1..0000000000 --- a/webapp/tests/Unit/Controller/Jury/JudgehostRestrictionsControllerTest.php +++ /dev/null @@ -1,36 +0,0 @@ - ['TestRestriction']]; - protected static $getIDFunc = 'getRestrictionid'; - protected static $className = JudgehostRestriction::class; - protected static $DOM_elements = ['h1' => ['Judgehost restrictions']]; - protected static $deleteFixtures = [AddJudgehostRestrictionFixture::class]; - protected static $addForm = 'judgehost_restriction['; - protected static $addEntitiesCount = ['contests','problems','languages']; - protected static $addEntitiesShown = ['name']; - protected static $addEntities = [['name' => 'Restriction', - 'contests' => ['0' => '1', '1' => '2'], - 'problems' => ['0' => '1', '1' => '2'], - 'languages' => ['0' => 'adb', '1' => 'awk'], - 'rejudge_own' => '1'], - ['name' => 'NonRestricted', - 'contests' => [], - 'problems' => [], - 'languages' => []], - ['name' => 'HighCountNumbers', - 'languages' => ['0' => 'adb', '1' => 'awk', '2' => 'swift', - '3' => 'r', '4' => 'rb', '5' => 'plg']], - ['name' => 'NoJudgeOwn', - 'rejudge_own' => '0']]; -} From ebe51e68729a572b698e1e5265aafbdc57cf9e6c Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Fri, 13 Aug 2021 22:04:22 +0200 Subject: [PATCH 2/5] Migration altered --- .../src/Migrations/Version20210813195818.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 webapp/src/Migrations/Version20210813195818.php diff --git a/webapp/src/Migrations/Version20210813195818.php b/webapp/src/Migrations/Version20210813195818.php new file mode 100644 index 0000000000..a6db04d258 --- /dev/null +++ b/webapp/src/Migrations/Version20210813195818.php @@ -0,0 +1,41 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE judgehost DROP FOREIGN KEY judgehost_ibfk_1'); + $this->addSql('DROP TABLE judgehost_restriction'); + $this->addSql('DROP INDEX restrictionid ON judgehost'); + $this->addSql('ALTER TABLE judgehost DROP restrictionid, CHANGE polltime polltime NUMERIC(32, 9) UNSIGNED DEFAULT NULL COMMENT \'Time of last poll by autojudger\''); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE judgehost_restriction (restrictionid INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Judgehost restriction ID\', name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'Descriptive name\', restrictions LONGTEXT CHARACTER SET utf8mb4 DEFAULT \'NULL\' COLLATE `utf8mb4_unicode_ci` COMMENT \'JSON-encoded restrictions(DC2Type:json)\', PRIMARY KEY(restrictionid)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'Restrictions for judgehosts\' '); + $this->addSql('ALTER TABLE judgehost ADD restrictionid INT UNSIGNED DEFAULT NULL COMMENT \'Judgehost restriction ID\', CHANGE polltime polltime NUMERIC(32, 9) UNSIGNED DEFAULT \'NULL\' COMMENT \'Time of last poll by autojudger\''); + $this->addSql('ALTER TABLE judgehost ADD CONSTRAINT judgehost_ibfk_1 FOREIGN KEY (restrictionid) REFERENCES judgehost_restriction (restrictionid) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX restrictionid ON judgehost (restrictionid)'); + } +} From ccce23ce414f95e9c412b21169e321220b55c5cf Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Sat, 14 Aug 2021 08:56:39 +0200 Subject: [PATCH 3/5] Update docs with mention of removed feature --- doc/manual/judging.rst | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/doc/manual/judging.rst b/doc/manual/judging.rst index 57e566af36..6f5ae3eff9 100644 --- a/doc/manual/judging.rst +++ b/doc/manual/judging.rst @@ -144,27 +144,8 @@ result with highest priority is returned. Judgehost restrictions ---------------------- -It is possible to dedicate certain judgehosts only for certain languages, -problems or contests; or a combination thereof. To set this up, configure -the desired restriction pattern under *Judgehost restrictions* from the -main menu. For example, you select contest 1 and language Java. -Then, you can edit all judgehosts and apply the newly created restriction -to any of them. The judgehosts with this restriction will only pick up -submissions that are in contest 1 *and* are submitted in Java. Submissions -for other languages, or in other contests, will need to be processed by -other judgehosts. - -When adding restrictions, take care that there must remain judgehosts -available to judge every active problem, language and contest. -The *Configuration checker* will perform a check for this. - -A special restriction is turning off *Allow rejudge on same judgehost*. -This defaults to Yes (so a rejudge of a submission can happen on any -judgehost), but you can add a judgehost restriction with this setting -to No. This can be used to test timings on judgehosts by configuring -all judgehosts with this restriction and then rejudging a set of submissions -as many times as there are judgehosts. This will lead to the situation that -each judgehosts has judged every submission exactly once. +In earlier releases <=7.3.3 it was possible to dedicate certain judgehosts only for certain languages, +problems or contests; or a combination thereof. This feature has been removed. Disk space and cleanup ---------------------- From ddbdeab0fab72e642b01624e566a0fd95d853c0a Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Sat, 14 Aug 2021 09:02:51 +0200 Subject: [PATCH 4/5] [Fixup] extra changes generated by doc:mig:diff removed --- webapp/src/Migrations/Version20210813195818.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/Migrations/Version20210813195818.php b/webapp/src/Migrations/Version20210813195818.php index a6db04d258..a111396340 100644 --- a/webapp/src/Migrations/Version20210813195818.php +++ b/webapp/src/Migrations/Version20210813195818.php @@ -25,7 +25,7 @@ public function up(Schema $schema) : void $this->addSql('ALTER TABLE judgehost DROP FOREIGN KEY judgehost_ibfk_1'); $this->addSql('DROP TABLE judgehost_restriction'); $this->addSql('DROP INDEX restrictionid ON judgehost'); - $this->addSql('ALTER TABLE judgehost DROP restrictionid, CHANGE polltime polltime NUMERIC(32, 9) UNSIGNED DEFAULT NULL COMMENT \'Time of last poll by autojudger\''); + $this->addSql('ALTER TABLE judgehost DROP restrictionid'); } public function down(Schema $schema) : void @@ -34,7 +34,7 @@ public function down(Schema $schema) : void $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); $this->addSql('CREATE TABLE judgehost_restriction (restrictionid INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Judgehost restriction ID\', name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'Descriptive name\', restrictions LONGTEXT CHARACTER SET utf8mb4 DEFAULT \'NULL\' COLLATE `utf8mb4_unicode_ci` COMMENT \'JSON-encoded restrictions(DC2Type:json)\', PRIMARY KEY(restrictionid)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'Restrictions for judgehosts\' '); - $this->addSql('ALTER TABLE judgehost ADD restrictionid INT UNSIGNED DEFAULT NULL COMMENT \'Judgehost restriction ID\', CHANGE polltime polltime NUMERIC(32, 9) UNSIGNED DEFAULT \'NULL\' COMMENT \'Time of last poll by autojudger\''); + $this->addSql('ALTER TABLE judgehost ADD restrictionid INT UNSIGNED DEFAULT NULL COMMENT \'Judgehost restriction ID\''); $this->addSql('ALTER TABLE judgehost ADD CONSTRAINT judgehost_ibfk_1 FOREIGN KEY (restrictionid) REFERENCES judgehost_restriction (restrictionid) ON DELETE SET NULL'); $this->addSql('CREATE INDEX restrictionid ON judgehost (restrictionid)'); } From 4dbe830379b87cb2f33c06fafd371a45299035a7 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Sat, 14 Aug 2021 09:05:17 +0200 Subject: [PATCH 5/5] Remove mention of non existing restriction feature --- doc/manual/judging.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/manual/judging.rst b/doc/manual/judging.rst index 6f5ae3eff9..d6e6907132 100644 --- a/doc/manual/judging.rst +++ b/doc/manual/judging.rst @@ -142,11 +142,6 @@ individual testcase results will be the overall submission result: the highest priority one. In case of a tie, the first occurring testcase result with highest priority is returned. -Judgehost restrictions ----------------------- -In earlier releases <=7.3.3 it was possible to dedicate certain judgehosts only for certain languages, -problems or contests; or a combination thereof. This feature has been removed. - Disk space and cleanup ---------------------- The judgehost caches testcase and executable data and stores various