Skip to content

Commit c03867c

Browse files
Make shadowing a bit more robust
All these were found while shadowing PC^2.
1 parent 40839ae commit c03867c

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

webapp/src/Command/ImportEventFeedCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ protected function compareContestId(): bool
223223
$ourId = $contest->getExternalid();
224224
$theirId = $this->sourceService->getContestId();
225225
if ($ourId !== $theirId) {
226-
$this->style->error(
226+
$this->style->warning(
227227
"Contest ID in external system $theirId does not match external ID in DOMjudge ($ourId)."
228228
);
229-
return false;
229+
if (!$this->style->confirm('Do you want to continue anyway?', default: false)) {
230+
return false;
231+
}
230232
}
231233

232234
return true;

webapp/src/DataTransferObject/ApiInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
class ApiInfo
88
{
99
public function __construct(
10-
public readonly string $version,
11-
public readonly string $versionUrl,
10+
public readonly ?string $version,
11+
public readonly ?string $versionUrl,
1212
public readonly string $name,
1313
public readonly ?ApiInfoProvider $provider,
1414
#[Serializer\Exclude(if: '!object.domjudge')]

webapp/src/DataTransferObject/Shadowing/ProblemEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ProblemEvent implements EventData
77
public function __construct(
88
public readonly string $id,
99
public readonly string $name,
10-
public readonly float $timeLimit,
10+
public readonly ?float $timeLimit,
1111
public readonly ?string $label,
1212
public readonly ?string $rgb,
1313
) {}

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,12 @@ protected function validateAndUpdateProblem(Event $event, EventData $data): void
10271027

10281028
$toCheckProblem = [
10291029
'name' => $data->name,
1030-
'timelimit' => $data->timeLimit,
10311030
];
10321031

1032+
if ($data->timeLimit) {
1033+
$toCheckProblem['timelimit'] = $data->timeLimit;
1034+
}
1035+
10331036
if ($contestProblem->getShortname() !== $data->label) {
10341037
$this->logger->warning(
10351038
'Contest problem short name does not match between feed (%s) and local (%s), updating',
@@ -1097,7 +1100,10 @@ protected function validateAndUpdateTeam(Event $event, EventData $data): void
10971100
if (!empty($data->organizationId)) {
10981101
$affiliation = $this->em->getRepository(TeamAffiliation::class)->findOneBy(['externalid' => $data->organizationId]);
10991102
if (!$affiliation) {
1103+
// Affiliation does not exist. Create one with a dummy name so we can continue.
11001104
$affiliation = new TeamAffiliation();
1105+
$affiliation->setName($data->organizationId);
1106+
$affiliation->setShortname($data->organizationId);
11011107
$this->em->persist($affiliation);
11021108
}
11031109
$team->setAffiliation($affiliation);
@@ -1106,7 +1112,9 @@ protected function validateAndUpdateTeam(Event $event, EventData $data): void
11061112
if (!empty($data->groupIds[0])) {
11071113
$category = $this->em->getRepository(TeamCategory::class)->findOneBy(['externalid' => $data->groupIds[0]]);
11081114
if (!$category) {
1115+
// Category does not exist. Create one with a dummy name so we can continue.
11091116
$category = new TeamCategory();
1117+
$category->setName($data->groupIds[0]);
11101118
$this->em->persist($category);
11111119
}
11121120
$team->setCategory($category);

0 commit comments

Comments
 (0)