From 1a0b40eb81a602dab32f6722b31c546a8d757079 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sat, 22 Jul 2023 19:34:11 +0200 Subject: [PATCH] Change compiler/runner version (commands) in API to conform with spec. (#2094) * Change compiler/runner version (commands) in API to conform with spec. See https://ccs-specs.icpc.io/draft/contest_api?highlight=languages#examples-5 * Fix null check --- webapp/src/Entity/Language.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/webapp/src/Entity/Language.php b/webapp/src/Entity/Language.php index 1e0e118448..fcf35c5a15 100644 --- a/webapp/src/Entity/Language.php +++ b/webapp/src/Entity/Language.php @@ -125,15 +125,19 @@ class Language extends BaseApiEntity private Collection $versions; #[ORM\Column(type: 'blobtext', nullable: true, options: ['comment' => 'Compiler version'])] + #[Serializer\Exclude] private ?string $compilerVersion = null; #[ORM\Column(type: 'blobtext', nullable: true, options: ['comment' => 'Runner version'])] + #[Serializer\Exclude] private ?string $runnerVersion = null; #[ORM\Column(type: 'string', length: 255, nullable: true, options: ['comment' => 'Runner version command'])] + #[Serializer\Exclude] private ?string $runnerVersionCommand = null; #[ORM\Column(type: 'string', length: 255, nullable: true, options: ['comment' => 'Compiler version command'])] + #[Serializer\Exclude] private ?string $compilerVersionCommand = null; /** @@ -207,6 +211,36 @@ public function getCompileExecutableHash(): ?string return $this->compile_executable?->getImmutableExecutable()->getHash(); } + #[Serializer\VirtualProperty] + #[Serializer\SerializedName('compiler')] + #[Serializer\Exclude(if:'object.getCompilerVersionCommand() == ""')] + public function getCompilerData(): ?array + { + $ret = []; + if (!empty($this->getCompilerVersionCommand())) { + $ret['version_command'] = $this->getCompilerVersionCommand(); + if (!empty($this->getCompilerVersion())) { + $ret['version'] = $this->getCompilerVersion(); + } + } + return $ret; + } + + #[Serializer\VirtualProperty] + #[Serializer\SerializedName('runner')] + #[Serializer\Exclude(if:'object.getRunnerVersionCommand() == ""')] + public function getRunnerData(): ?array + { + $ret = []; + if (!empty($this->getRunnerVersionCommand())) { + $ret['version_command'] = $this->getRunnerVersionCommand(); + if (!empty($this->getRunnerVersion())) { + $ret['version'] = $this->getRunnerVersion(); + } + } + return $ret; + } + public function setLangid(string $langid): Language { $this->langid = $langid;