Skip to content

Commit c21737e

Browse files
committed
Display a simple selection menu to trigger the task
We can either pass the externalid or the id of the immutableexecutable. For now I went with the externalid as the immutable makes that it can be cached and we can use the wrong URL bij accident. The advantage of using the immutable is that we get some extra info about which versions were ran via the log. The same thing can be extracted from the judgetask table.
1 parent ca86bc0 commit c21737e

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

webapp/src/Controller/Jury/JudgehostController.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Controller\BaseController;
66
use App\Doctrine\DBAL\Types\JudgeTaskType;
7+
use App\Entity\Executable;
78
use App\Entity\Judgehost;
89
use App\Entity\JudgeTask;
910
use App\Entity\Judging;
@@ -210,8 +211,19 @@ public function indexAction(Request $request): Response
210211
return strnatcasecmp($a['data']['hostname']['value'], $b['data']['hostname']['value']);
211212
});
212213

214+
/** @var Executable[] $executables */
215+
$executables = $this->em->createQueryBuilder()
216+
->select('e as executable, e.execid as execid')
217+
->from(Executable::class, 'e')
218+
->addOrderBy('e.type', 'ASC')
219+
->addOrderBy('e.execid', 'ASC')
220+
->andWhere('e.type = :type')
221+
->setParameter('type', JudgeTaskType::GENERIC_TASK)
222+
->getQuery()->getResult();
223+
213224
$data = [
214225
'judgehosts' => $judgehosts_table,
226+
'executables' => $executables,
215227
'table_fields' => $table_fields,
216228
'all_checked_in_recently' => $all_checked_in_recently,
217229
'refresh' => [
@@ -278,7 +290,18 @@ public function viewAction(Request $request, int $judgehostid): Response
278290
->getResult();
279291
}
280292

293+
/** @var Executable[] $executables */
294+
$executables = $this->em->createQueryBuilder()
295+
->select('e as executable, e.execid as execid')
296+
->from(Executable::class, 'e')
297+
->addOrderBy('e.type', 'ASC')
298+
->addOrderBy('e.execid', 'ASC')
299+
->andWhere('e.type = :type')
300+
->setParameter('type', JudgeTaskType::GENERIC_TASK)
301+
->getQuery()->getResult();
302+
281303
$data = [
304+
'executables' => $executables,
282305
'judgehost' => $judgehost,
283306
'status' => $status,
284307
'statusIcon' => $statusIcon,
@@ -296,10 +319,10 @@ public function viewAction(Request $request, int $judgehostid): Response
296319
}
297320
}
298321

299-
private function helperGenericTask(int $execid, ?JudgeHost $judgehost = null): void {
322+
private function helperGenericTask(string $execid, ?JudgeHost $judgehost = null): void {
300323
$executable = $this->em->getRepository(Executable::class)->findOneBy(['execid' => $execid]);
301324
if (!$executable) {
302-
throw new NotFoundHttpException(sprintf('Executable with ID %d not found', $execid));
325+
throw new NotFoundHttpException(sprintf('Executable with ID %s not found', $execid));
303326
}
304327

305328
$executable = $executable->getImmutableExecutable();
@@ -329,7 +352,7 @@ private function helperGenericTask(int $execid, ?JudgeHost $judgehost = null): v
329352

330353
#[IsGranted('ROLE_ADMIN')]
331354
#[Route(path: '/{judgehostid}/request-generic-task/{execid}', name: 'jury_request_judgehost_generic')]
332-
public function requestGenericTaskJudgehost(Request $request, int $judgehostid, int $execid): RedirectResponse
355+
public function requestGenericTaskJudgehost(Request $request, int $judgehostid, string $execid): RedirectResponse
333356
{
334357
$judgehost = $this->em->getRepository(Judgehost::class)->find($judgehostid);
335358
if (!$judgehost) {
@@ -346,7 +369,7 @@ public function requestGenericTaskJudgehost(Request $request, int $judgehostid,
346369
// TODO: Does the ordering matter in the file.
347370
#[IsGranted('ROLE_ADMIN')]
348371
#[Route(path: '/request-generic-task/{execid}', name: 'jury_request_generic')]
349-
public function requestGenericTask(Request $request, int $execid): RedirectResponse
372+
public function requestGenericTask(Request $request, string $execid): RedirectResponse
350373
{
351374
$this->helperGenericTask($execid);
352375
return $this->redirectToRoute('jury_judgehost', [

webapp/templates/jury/judgehost.html.twig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@
6767
{% include 'jury/partials/judgehost_judgings.html.twig' %}
6868
</div>
6969

70+
<div>
71+
<h3>Request generic actions</h3>
72+
{% for executable in executables %}
73+
<a href="{{ path('jury_request_judgehost_generic', {'execid': executable.executable.execid, 'judgehostid': judgehost.judgehostid}) }}">
74+
{{ executable.executable.description }}
75+
</a><br>
76+
{% endfor %}
77+
</div>
78+
7079
{% endblock %}

webapp/templates/jury/judgehosts.html.twig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,37 @@
4444
{{ button(path('jury_judgehost_edit'), 'Edit all judgehosts', 'secondary', 'edit') }}
4545
</div>
4646
</div>
47+
<div>
48+
<table border="1">
49+
<thead>
50+
<tr>
51+
<th rowspan="2">Executable</th>
52+
<th colspan="{{ judgehosts | length + 1}}">Judgehost</th>
53+
</tr>
54+
<tr>
55+
<th>All</th>
56+
{% for judgehost in judgehosts %}
57+
<th>{{ judgehost.data.hostname.value }}</th>
58+
{% endfor %}
59+
</tr>
60+
</thead>
61+
<tbody>
62+
{% for executable in executables %}
63+
<tr>
64+
<td>{{ executable.executable.description }}</td>
65+
<td>
66+
<a href="{{ path('jury_request_generic', {'execid': executable.execid}) }}">All</a>
67+
</td>
68+
{% for judgehost in judgehosts %}
69+
<td>
70+
<a href="{{ path('jury_request_judgehost_generic', {'execid': executable.execid, 'judgehostid': judgehost.data.judgehostid.value}) }}">{{ judgehost.data.hostname.value }}</a>
71+
</td>
72+
{% endfor %}
73+
</tr>
74+
{% endfor %}
75+
</tbody>
76+
</table>
77+
</div>
4778

4879
{%- endif %}
4980

0 commit comments

Comments
 (0)