Skip to content

Commit 270da02

Browse files
committed
Record submission source in database.
The motivation for this is that we can use the data to fix the various errors we have seen across the interface when shadowing one by one. But it can also be useful for other reasons, e.g. being able to count how many submissions were received via the API vs web UI.
1 parent 8c11ace commit 270da02

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250907161952 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return 'Add submission source to submission info.';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE submission ADD source VARCHAR(255) NOT NULL DEFAULT \'unknown\' COMMENT \'Where did we receive this submission from?\'');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE submission DROP source');
30+
}
31+
32+
public function isTransactional(): bool
33+
{
34+
return false;
35+
}
36+
}

webapp/src/Entity/Submission.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ class Submission extends BaseApiEntity implements
102102
#[Serializer\Groups([ARC::GROUP_NONSTRICT])]
103103
private ?string $importError = null;
104104

105+
#[ORM\Column(options: [
106+
'comment' => 'Where did we receive this submission from?',
107+
])]
108+
#[Serializer\Exclude]
109+
private SubmissionSource $source = SubmissionSource::UNKNOWN;
110+
105111
#[ORM\ManyToOne(inversedBy: 'submissions')]
106112
#[ORM\JoinColumn(name: 'cid', referencedColumnName: 'cid', onDelete: 'CASCADE')]
107113
#[Serializer\Exclude]
@@ -573,4 +579,15 @@ public function getFileForApi(): array
573579
{
574580
return array_filter([$this->fileForApi]);
575581
}
582+
583+
public function setSource(SubmissionSource $source): Submission
584+
{
585+
$this->source = $source;
586+
return $this;
587+
}
588+
589+
public function getSource(): SubmissionSource
590+
{
591+
return $this->source;
592+
}
576593
}

webapp/src/Service/SubmissionService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ public function submitSolution(
700700
->setOriginalSubmission($originalSubmission)
701701
->setEntryPoint($entryPoint)
702702
->setExternalid($externalId)
703-
->setImportError($importError);
703+
->setImportError($importError)
704+
->setSource($source);
704705

705706
// Add expected results from source. We only do this for jury submissions
706707
// to prevent accidental auto-verification of team submissions.

0 commit comments

Comments
 (0)