Skip to content

Commit 073e433

Browse files
vmcjnickygerritsen
andcommitted
Simplify code by doing this check as part of the ContestProblem
The same check is needed for another PR and this makes it much easier to read. Co-authored-by: Nicky Gerritsen <nickygerritsen@me.com>
1 parent fc16b45 commit 073e433

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

webapp/src/Entity/ContestProblem.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php declare(strict_types=1);
22
namespace App\Entity;
33

4+
use App\Service\DOMJudgeService as DJS;
45
use App\Service\EventLogService;
56
use App\Utils\Utils;
67
use Doctrine\Common\Collections\ArrayCollection;
@@ -204,6 +205,16 @@ public function getLazyEvalResults(): int
204205
return $this->lazyEvalResults;
205206
}
206207

208+
public function determineOnDemand(int $config_lazy_eval_results): bool {
209+
if ($this->lazyEvalResults === DJS::EVAL_DEMAND) {
210+
return true;
211+
}
212+
if ($this->lazyEvalResults === DJS::EVAL_DEFAULT && $config_lazy_eval_results === DJS:: EVAL_DEMAND) {
213+
return true;
214+
}
215+
return false;
216+
}
217+
207218
public function setContest(?Contest $contest = null): ContestProblem
208219
{
209220
$this->contest = $contest;

webapp/src/Service/DOMJudgeService.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,7 @@ public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTas
11631163

11641164
$evalOnDemand = false;
11651165
// We have 2 cases, the problem picks the global value or the value is set.
1166-
if (($problem->getLazyEvalResults() === DOMJudgeService::EVAL_DEFAULT && $this->config->get('lazy_eval_results') === static::EVAL_DEMAND)
1167-
|| $problem->getLazyEvalResults() === DOMJudgeService::EVAL_DEMAND) {
1166+
if ($problem->determineOnDemand($this->config->get('lazy_eval_results'))) {
11681167
$evalOnDemand = true;
11691168

11701169
// Special case, we're shadow and someone submits on our side in that case

0 commit comments

Comments
 (0)