Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion webapp/src/Controller/API/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,8 @@ private function maybeUpdateActiveJudging(Judging $judging): void
->getQuery()
->setHint(Query::HINT_REFRESH, TRUE)
->getResult();
$this->rejudgingService->createRejudging($rejudging->getReason(), $judgings,
// TOOD: Pick up priority from previous judgings?
$this->rejudgingService->createRejudging($rejudging->getReason(), JudgeTask::PRIORITY_DEFAULT, $judgings,
false, $rejudging->getRepeat(), $rejudging->getRepeatedRejudging(), $skipped);
}
}
Expand Down
9 changes: 6 additions & 3 deletions webapp/src/Controller/Jury/RejudgingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Controller\BaseController;
use App\Entity\Contest;
use App\Entity\Judgehost;
use App\Entity\JudgeTask;
use App\Entity\Judging;
use App\Entity\JudgingRun;
use App\Entity\Language;
Expand Down Expand Up @@ -471,6 +472,7 @@ public function addAction(Request $request, FormFactoryInterface $formFactory):
$formData = $form->getData();
$data = [
'reason' => $formData['reason'],
'priority' => JudgeTask::parsePriority($formData['priority']),
'repeat' => $formData['repeat'],
'contests' => array_map(function (Contest $contest) {
return $contest->getCid();
Expand Down Expand Up @@ -588,7 +590,7 @@ public function addAction(Request $request, FormFactoryInterface $formFactory):

$skipped = [];
$res = $this->rejudgingService->createRejudging(
$reason, $judgings, false, (int)$data['repeat'] ?? 1, null, $skipped, $progressReporter);
$reason, $data['priority'], $judgings, false, (int)$data['repeat'] ?? 1, null, $skipped, $progressReporter);
$this->generateFlashMessagesForSkippedJudgings($skipped);

if ($res === null) {
Expand Down Expand Up @@ -620,6 +622,7 @@ public function createAction(Request $request): Response
$includeAll = (bool)$request->request->get('include_all');
$autoApply = (bool)$request->request->get('auto_apply');
$repeat = (int)$request->request->get('repeat');
$priority = $request->request->get('priority') ?: 'default';

if (empty($table) || empty($id)) {
throw new BadRequestHttpException('No table or id passed for selection in rejudging');
Expand Down Expand Up @@ -672,7 +675,7 @@ public function createAction(Request $request): Response
flush();
};

return $this->streamResponse(function() use ($progressReporter, $repeat, $reason, $request, $autoApply, $includeAll, $id, $table, $tablemap) {
return $this->streamResponse(function() use ($priority, $progressReporter, $repeat, $reason, $request, $autoApply, $includeAll, $id, $table, $tablemap) {
// Only rejudge submissions in active contests.
$contests = $this->dj->getCurrentContests();

Expand Down Expand Up @@ -719,7 +722,7 @@ public function createAction(Request $request): Response
}

$skipped = [];
$res = $this->rejudgingService->createRejudging($reason, $judgings, $autoApply, $repeat, null, $skipped, $progressReporter);
$res = $this->rejudgingService->createRejudging($reason, JudgeTask::parsePriority($priority), $judgings, $autoApply, $repeat, null, $skipped, $progressReporter);
$this->generateFlashMessagesForSkippedJudgings($skipped);

if ($res === null) {
Expand Down
12 changes: 12 additions & 0 deletions webapp/src/Entity/JudgeTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,16 @@ public function getStarttime()
{
return $this->starttime;
}

public static function parsePriority(string $priorityString): int {
switch ($priorityString) {
case 'low':
return JudgeTask::PRIORITY_LOW;
case 'high':
return JudgeTask::PRIORITY_HIGH;
default:
return JudgeTask::PRIORITY_DEFAULT;

}
}
}
10 changes: 10 additions & 0 deletions webapp/src/Form/Type/RejudgingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public function __construct(EntityManagerInterface $em)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('reason', TextType::class);
$builder->add('priority', ChoiceType::class,
[
'choices' => [
'low' => 'low',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not set the keys (or values, I always forget) to the actual prio numbers? Symfony will validate you actually pass a valid value so you can’t “hack” the form and specify something else (well technically because we have the Ajax in between you could but 🤷‍♂️)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use curl or httpie, and I don't want to accept arbitrary priorities.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point

'default' => 'default',
'high' => 'high',
],
'data' => 'default',
]
);
$builder->add('repeat', IntegerType::class, [
'label' => 'Number of times to repeat this rejudging',
'data' => 1,
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Service/DOMJudgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ public function unblockJudgeTasksForProblem(int $probId): void
}
}

public function maybeCreateJudgeTasks(Judging $judging): void
public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT): void
{
$submission = $judging->getSubmission();
$problem = $submission->getContestProblem();
Expand Down Expand Up @@ -1107,7 +1107,7 @@ public function maybeCreateJudgeTasks(Judging $judging): void
$judgetaskInsertParams = [
':type' => JudgeTaskType::JUDGING_RUN,
':submitid' => $submission->getSubmitid(),
':priority' => JudgeTask::PRIORITY_DEFAULT,
':priority' => $priority,
':jobid' => $judging->getJudgingid(),
':compile_script_id' => $compileExecutable->getImmutableExecId(),
':compare_script_id' => $compareExecutable->getImmutableExecId(),
Expand Down
4 changes: 3 additions & 1 deletion webapp/src/Service/RejudgingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function __construct(
*/
public function createRejudging(
string $reason,
int $priority,
array $judgings,
bool $autoApply,
int $repeat,
Expand Down Expand Up @@ -129,6 +130,7 @@ public function createRejudging(
}

$this->em->transactional(function () use (
$priority,
$singleJudging,
$judging,
$rejudging
Expand Down Expand Up @@ -164,7 +166,7 @@ public function createRejudging(
$this->em->persist($newJudging);
$this->em->flush();

$this->dj->maybeCreateJudgeTasks($newJudging);
$this->dj->maybeCreateJudgeTasks($newJudging, $priority);
});

if ($index > 1) {
Expand Down
8 changes: 8 additions & 0 deletions webapp/templates/jury/partials/rejudge_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
<label for="reason">Reason</label>
<input type="text" class="form-control" name="reason" id="reason" maxlength="255">
</div>
<div id="rejudge-priority" class="form-group">
<label for="priority">Priority</label>
<select class="form-control" name="priority" id="priority">
<option value="low">low</option>
<option value="default" selected>default</option>
<option value="high">high</option>
</select>
</div>
{% endif %}
</div>
<div class="modal-footer">
Expand Down