Skip to content

Commit

Permalink
Make shadowing a bit more robust
Browse files Browse the repository at this point in the history
All these were found while shadowing PC^2.
  • Loading branch information
nickygerritsen committed Nov 12, 2024
1 parent 40839ae commit c03867c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions webapp/src/Command/ImportEventFeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@ protected function compareContestId(): bool
$ourId = $contest->getExternalid();
$theirId = $this->sourceService->getContestId();
if ($ourId !== $theirId) {
$this->style->error(
$this->style->warning(
"Contest ID in external system $theirId does not match external ID in DOMjudge ($ourId)."
);
return false;
if (!$this->style->confirm('Do you want to continue anyway?', default: false)) {
return false;
}
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/DataTransferObject/ApiInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class ApiInfo
{
public function __construct(
public readonly string $version,
public readonly string $versionUrl,
public readonly ?string $version,
public readonly ?string $versionUrl,
public readonly string $name,
public readonly ?ApiInfoProvider $provider,
#[Serializer\Exclude(if: '!object.domjudge')]
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/DataTransferObject/Shadowing/ProblemEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ProblemEvent implements EventData
public function __construct(
public readonly string $id,
public readonly string $name,
public readonly float $timeLimit,
public readonly ?float $timeLimit,
public readonly ?string $label,
public readonly ?string $rgb,
) {}
Expand Down
10 changes: 9 additions & 1 deletion webapp/src/Service/ExternalContestSourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,12 @@ protected function validateAndUpdateProblem(Event $event, EventData $data): void

$toCheckProblem = [
'name' => $data->name,
'timelimit' => $data->timeLimit,
];

if ($data->timeLimit) {
$toCheckProblem['timelimit'] = $data->timeLimit;
}

if ($contestProblem->getShortname() !== $data->label) {
$this->logger->warning(
'Contest problem short name does not match between feed (%s) and local (%s), updating',
Expand Down Expand Up @@ -1097,7 +1100,10 @@ protected function validateAndUpdateTeam(Event $event, EventData $data): void
if (!empty($data->organizationId)) {
$affiliation = $this->em->getRepository(TeamAffiliation::class)->findOneBy(['externalid' => $data->organizationId]);
if (!$affiliation) {
// Affiliation does not exist. Create one with a dummy name so we can continue.
$affiliation = new TeamAffiliation();
$affiliation->setName($data->organizationId);
$affiliation->setShortname($data->organizationId);
$this->em->persist($affiliation);
}
$team->setAffiliation($affiliation);
Expand All @@ -1106,7 +1112,9 @@ protected function validateAndUpdateTeam(Event $event, EventData $data): void
if (!empty($data->groupIds[0])) {
$category = $this->em->getRepository(TeamCategory::class)->findOneBy(['externalid' => $data->groupIds[0]]);
if (!$category) {
// Category does not exist. Create one with a dummy name so we can continue.
$category = new TeamCategory();
$category->setName($data->groupIds[0]);
$this->em->persist($category);
}
$team->setCategory($category);
Expand Down

0 comments on commit c03867c

Please sign in to comment.