Skip to content

Allow shadowing from PC2 #2343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f40818
Shadow differences: redirect to configure page if not set up yet.
nickygerritsen Feb 13, 2024
b35e850
Also create submission if the source is not a ZIP.
nickygerritsen Feb 13, 2024
948dae4
Show import errors as shadow differences in menu count.
nickygerritsen Feb 13, 2024
30a4448
Install and enable serializer.
nickygerritsen Feb 13, 2024
69f46c3
Add provider data to API info.
nickygerritsen Feb 13, 2024
20687ae
Use DTO's for cached contest and API info data in external contest se…
nickygerritsen Feb 13, 2024
9ffb0ba
Use DTO's and the Symfony Serializer component for reading external c…
nickygerritsen Feb 14, 2024
7f883d8
Fix test for general info API.
nickygerritsen Feb 15, 2024
30032d4
Update webapp/src/Controller/API/GeneralInfoController.php
nickygerritsen Feb 15, 2024
2b9b930
Update webapp/src/Service/ExternalContestSourceService.php
nickygerritsen Feb 15, 2024
34c2cfe
Get rid of all fields from event DTO's we don't (currently) use.
nickygerritsen Feb 15, 2024
6eb5709
Add todo for checking some contest times.
nickygerritsen Feb 16, 2024
d10ca54
Don't use negation in ternary.
nickygerritsen Feb 26, 2024
cbd96f6
Restore formatting of file to not have a big diff.
nickygerritsen Feb 26, 2024
23e7726
Rename event data normalizer to denormalizer since that is all it does.
nickygerritsen Feb 26, 2024
78c1edc
Add tests for event parsing.
nickygerritsen Feb 26, 2024
7570245
Get rid of unused event classes.
nickygerritsen Feb 26, 2024
356e8ee
When calculating external source warning, the entity ID might be null.
nickygerritsen Feb 27, 2024
59719ff
State events do no not have an ID.
nickygerritsen Feb 27, 2024
7b13e51
Fix missing change from array to DTO.
nickygerritsen Feb 27, 2024
55f7965
Allow shadowing from PC2
vmcj Feb 27, 2024
7738ffc
The millisecond is optional
vmcj Feb 27, 2024
2a3e6b3
Disable short-name check against PC2
vmcj Feb 24, 2024
fc72e22
Be lenient as we can reasonably assume this is a ZIP file
vmcj Feb 24, 2024
35a75dd
Protect against baseURLs ending with a '/'
vmcj Feb 24, 2024
50061ca
Allow longer config options
vmcj Feb 24, 2024
1f7e467
Fix regex
vmcj Feb 27, 2024
b4cdfbe
PC^2 does not send timelimits for problems, so make them optional.
nickygerritsen Feb 27, 2024
6ae92b2
Drop double / between base path and relative URL's.
nickygerritsen Feb 27, 2024
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
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"mbostock/d3": "^3.5",
"nelmio/api-doc-bundle": "^4.11",
"novus/nvd3": "^1.8",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.25",
"promphp/prometheus_client_php": "^2.6",
"ramsey/uuid": "^4.2",
"select2/select2": "4.*",
Expand All @@ -89,9 +91,12 @@
"symfony/intl": "6.4.*",
"symfony/mime": "6.4.*",
"symfony/monolog-bundle": "^3.8.0",
"symfony/property-access": "6.4.*",
"symfony/property-info": "6.4.*",
"symfony/runtime": "6.4.*",
"symfony/security-bundle": "6.4.*",
"symfony/security-csrf": "6.4.*",
"symfony/serializer": "6.4.*",
"symfony/stopwatch": "6.4.*",
"symfony/twig-bundle": "6.4.*",
"symfony/validator": "6.4.*",
Expand Down
102 changes: 100 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions webapp/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ framework:
http_method_override: true
annotations: true
handle_all_throwables: true
serializer:
enabled: true
name_converter: serializer.name_converter.camel_case_to_snake_case

# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
Expand Down
36 changes: 36 additions & 0 deletions webapp/migrations/Version20240224115108.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240224115108 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE configuration CHANGE name name VARCHAR(64) NOT NULL COMMENT \'Name of the configuration variable\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE configuration CHANGE name name VARCHAR(32) NOT NULL COMMENT \'Name of the configuration variable\'');
}

public function isTransactional(): bool
{
return false;
}
}
6 changes: 6 additions & 0 deletions webapp/src/Controller/API/GeneralInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Controller\API;

use App\DataTransferObject\ApiInfo;
use App\DataTransferObject\ApiInfoProvider;
use App\DataTransferObject\ApiVersion;
use App\DataTransferObject\DomJudgeApiInfo;
use App\DataTransferObject\ExtendedContestStatus;
Expand Down Expand Up @@ -99,6 +100,11 @@ public function getInfoAction(
version: self::CCS_SPEC_API_VERSION,
versionUrl: self::CCS_SPEC_API_URL,
name: 'DOMjudge',
//TODO: Add DOMjudge logo
provider: new ApiInfoProvider(
name: 'DOMjudge',
version: $this->getParameter('domjudge.version'),
),
domjudge: $domjudge
);
}
Expand Down
14 changes: 14 additions & 0 deletions webapp/src/Controller/Jury/ShadowDifferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Controller\Jury;

use App\DataTransferObject\SubmissionRestriction;
use App\Entity\ExternalContestSource;
use App\Service\ConfigurationService;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NonUniqueResultException;
Expand Down Expand Up @@ -64,6 +65,19 @@ public function indexAction(
return $this->redirectToRoute('jury_index');
}

/** @var ExternalContestSource|null $externalContestSource */
$externalContestSource = $this->em->createQueryBuilder()
->from(ExternalContestSource::class, 'ecs')
->select('ecs')
->andWhere('ecs.contest = :contest')
->setParameter('contest', $this->dj->getCurrentContest())
->getQuery()->getOneOrNullResult();

if (!$externalContestSource) {
$this->addFlash('warning', 'No external contest present yet, please configure one first');
return $this->redirectToRoute('jury_external_contest_manage');
}

// Close the session, as this might take a while and we don't need the session below.
$this->requestStack->getSession()->save();

Expand Down
1 change: 1 addition & 0 deletions webapp/src/DataTransferObject/ApiInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function __construct(
public readonly string $version,
public readonly string $versionUrl,
public readonly string $name,
public readonly ?ApiInfoProvider $provider,
#[Serializer\Exclude(if: '!object.domjudge')]
public readonly ?DomJudgeApiInfo $domjudge,
) {}
Expand Down
15 changes: 15 additions & 0 deletions webapp/src/DataTransferObject/ApiInfoProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject;

use JMS\Serializer\Annotation as Serializer;

class ApiInfoProvider
{
public function __construct(
public readonly string $name,
public readonly string $version,
#[Serializer\Exclude(if: '!object.buildDate')]
public readonly ?string $buildDate = null,
) {}
}
16 changes: 16 additions & 0 deletions webapp/src/DataTransferObject/Shadowing/ClarificationEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject\Shadowing;

class ClarificationEvent implements EventData
{
public function __construct(
public readonly string $id,
public readonly string $text,
public readonly string $time,
public readonly ?string $fromTeamId,
public readonly ?string $toTeamId,
public readonly ?string $replyToId,
public readonly ?string $problemId,
) {}
}
16 changes: 16 additions & 0 deletions webapp/src/DataTransferObject/Shadowing/ContestData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject\Shadowing;

class ContestData
{
public function __construct(
public readonly string $id,
public readonly string $name,
public readonly string $duration,
public readonly ?string $scoreboardFreezeDuration,
public readonly int $penaltyTime,
public readonly ?string $startTime,
// TODO: check for end time and scoreboard thaw time
) {}
}
19 changes: 19 additions & 0 deletions webapp/src/DataTransferObject/Shadowing/ContestEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject\Shadowing;

class ContestEvent implements EventData
{
public function __construct(
public readonly string $id,
public readonly string $name,
public readonly string $duration,
public readonly ?string $scoreboardType,
public readonly int $penaltyTime,
public readonly ?string $formalName,
public readonly ?string $startTime,
public readonly ?int $countdownPauseTime,
public readonly ?string $scoreboardFreezeDuration,
public readonly ?string $scoreboardThawTime,
) {}
}
20 changes: 20 additions & 0 deletions webapp/src/DataTransferObject/Shadowing/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject\Shadowing;

/**
* @template-covariant T of EventData
*/
class Event
{
/**
* @param T[] $data
*/
public function __construct(
public readonly ?string $id,
public readonly EventType $type,
public readonly Operation $operation,
public readonly ?string $objectId,
public readonly array $data,
) {}
}
8 changes: 8 additions & 0 deletions webapp/src/DataTransferObject/Shadowing/EventData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);

namespace App\DataTransferObject\Shadowing;

interface EventData
{

}
Loading