Skip to content

Commit 9c5f04a

Browse files
Add current to judgement endpoint
1 parent 8ca6ae3 commit 9c5f04a

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

webapp/src/Controller/API/AbstractRestController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Controller\API;
44

55
use App\Entity\BaseApiEntity;
6+
use App\Utils\CcsApiVersion;
67
use Doctrine\ORM\NonUniqueResultException;
78
use Doctrine\ORM\QueryBuilder;
89
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -73,7 +74,9 @@ protected function renderData(
7374
$view->getContext()->setAttribute('domjudge_service', $this->dj);
7475
$view->getContext()->setAttribute('config_service', $this->config);
7576

76-
$groups = [static::GROUP_DEFAULT];
77+
/** @var CcsApiVersion $ccsApiVersion */
78+
$ccsApiVersion = $this->config->get('ccs_api_version');
79+
$groups = [static::GROUP_DEFAULT, $ccsApiVersion->value];
7780
if (!$request->query->has('strict') || !$request->query->getBoolean('strict')) {
7881
$groups[] = static::GROUP_NONSTRICT;
7982
}

webapp/src/Controller/API/AccessController.php

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

55
use App\DataTransferObject\Access;
66
use App\DataTransferObject\AccessEndpoint;
7+
use App\Utils\CcsApiVersion;
78
use Doctrine\ORM\NonUniqueResultException;
89
use Doctrine\ORM\NoResultException;
910
use FOS\RestBundle\Controller\Annotations as Rest;
@@ -99,6 +100,9 @@ public function getStatusAction(Request $request): Access
99100
$capabilities[] = 'admin_clar';
100101
}
101102

103+
/** @var CcsApiVersion $ccsApiVersion */
104+
$ccsApiVersion = $this->config->get('ccs_api_version');
105+
102106
return new Access(
103107
capabilities: $capabilities,
104108
endpoints: [
@@ -252,6 +256,7 @@ public function getStatusAction(Request $request): Access
252256
'end_time',
253257
'end_contest_time',
254258
'max_run_time',
259+
'current',
255260
// DOMjudge specific properties:
256261
'valid',
257262
],

webapp/src/Entity/Judging.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ public function getValid(): bool
335335
return $this->valid;
336336
}
337337

338+
// Note: we can't use CCSApiVersion::Format_2025_DRAFT->value in PHP 8.1, only in 8.2+
339+
#[Serializer\Groups([ARC::GROUP_NONSTRICT, '2025-draft'])]
340+
#[Serializer\VirtualProperty]
341+
public function getCurrent(): bool
342+
{
343+
return $this->getValid();
344+
}
345+
338346
/**
339347
* @param resource|string $outputCompile
340348
*/

webapp/tests/Unit/Controller/API/AccessControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testAccessAsAdmin(): void
3939
'accounts' => ['id', 'username', 'name', 'type'],
4040
'state' => ['started', 'frozen', 'ended', 'thawed', 'finalized', 'end_of_updates'],
4141
'submissions' => ['id', 'language_id', 'problem_id', 'team_id', 'time', 'contest_time', 'entry_point', 'files'],
42-
'judgements' => ['id', 'submission_id', 'judgement_type_id', 'start_time', 'start_contest_time', 'end_time', 'end_contest_time', 'max_run_time'],
42+
'judgements' => ['id', 'submission_id', 'judgement_type_id', 'start_time', 'start_contest_time', 'end_time', 'end_contest_time', 'max_run_time', 'current'],
4343
'runs' => ['id', 'judgement_id', 'ordinal', 'judgement_type_id', 'time', 'contest_time', 'run_time'],
4444
'clarifications' => ['id', 'from_team_id', 'problem_id', 'text', 'time', 'contest_time'],
4545
'awards' => ['id', 'citation', 'team_ids'],

0 commit comments

Comments
 (0)