Skip to content

Commit

Permalink
Allow reimporting existing contests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj authored Sep 29, 2023
1 parent 328f534 commit da4d3ea
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,15 @@ public function importContestData(mixed $data, ?string &$errorMessage = null, st
return false;
}

$contest = new Contest();
$newShortNameAndExternalId = preg_replace(preg_replace(
$invalid_regex,
'_',
$data['short_name'] ?? $data['shortname'] ?? $data['short-name'] ?? $data['id']
);
$contest = $this->em->getRepository(Contest::class)->findOneBy(['externalid' => $newShortNameAndExternalId]) ?: new Contest();
$contest
->setName($data['name'] ?? $data['formal_name'] )
->setShortname(preg_replace(
$invalid_regex,
'_',
$data['short_name'] ?? $data['shortname'] ?? $data['short-name'] ?? $data['id']
))
->setShortname($newShortNameAndExternalId)
->setExternalid($contest->getShortname())
->setWarningMessage($data['warning-message'] ?? null)
->setStarttimeString(date_format($startTime, 'Y-m-d H:i:s e'))
Expand Down

0 comments on commit da4d3ea

Please sign in to comment.