Skip to content

Commit d63fc20

Browse files
Allow multiple categories per team
Part of #2937 � Conflicts: � webapp/src/Service/ImportExportService.php
1 parent d708684 commit d63fc20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+363
-156
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 Version20250620090108 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
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('CREATE TABLE team_category_team (categoryid INT UNSIGNED NOT NULL COMMENT \'Team category ID\', teamid INT UNSIGNED NOT NULL COMMENT \'Team ID\', INDEX IDX_3A19F9C99B32FD3 (categoryid), INDEX IDX_3A19F9C94DD6ABF3 (teamid), PRIMARY KEY(categoryid, teamid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
24+
$this->addSql('ALTER TABLE team_category_team ADD CONSTRAINT FK_3A19F9C99B32FD3 FOREIGN KEY (categoryid) REFERENCES team_category (categoryid) ON DELETE CASCADE');
25+
$this->addSql('ALTER TABLE team_category_team ADD CONSTRAINT FK_3A19F9C94DD6ABF3 FOREIGN KEY (teamid) REFERENCES team (teamid) ON DELETE CASCADE');
26+
$this->addSql('INSERT INTO team_category_team (categoryid, teamid) SELECT categoryid, teamid FROM team');
27+
$this->addSql('ALTER TABLE team DROP FOREIGN KEY team_ibfk_1');
28+
$this->addSql('DROP INDEX categoryid ON team');
29+
$this->addSql('ALTER TABLE team DROP categoryid');
30+
}
31+
32+
public function down(Schema $schema): void
33+
{
34+
// this down() migration is auto-generated, please modify it to your needs
35+
$this->addSql('ALTER TABLE team ADD categoryid INT UNSIGNED DEFAULT NULL COMMENT \'Team category ID\'');
36+
$this->addSql('ALTER TABLE team ADD CONSTRAINT team_ibfk_1 FOREIGN KEY (categoryid) REFERENCES team_category (categoryid) ON DELETE CASCADE');
37+
$this->addSql('CREATE INDEX categoryid ON team (categoryid)');
38+
$this->addSql('UPDATE team SET categoryid = (SELECT MIN(categoryid) from team_category_team WHERE team_category_team.teamid = team.teamid)');
39+
$this->addSql('ALTER TABLE team_category_team DROP FOREIGN KEY FK_3A19F9C99B32FD3');
40+
$this->addSql('ALTER TABLE team_category_team DROP FOREIGN KEY FK_3A19F9C94DD6ABF3');
41+
$this->addSql('DROP TABLE team_category_team');
42+
}
43+
44+
public function isTransactional(): bool
45+
{
46+
return false;
47+
}
48+
}

webapp/src/Command/ScoreboardMergeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
220220
$teamObj->setAffiliation($affiliations[$organizationName]);
221221
}
222222

223-
$teamObj->setCategory($category);
223+
$teamObj->addCategory($category);
224224
$oldid = $team['id'];
225225
$newid = $nextTeamId++;
226226
$teamObj->setTeamid($newid);

webapp/src/Controller/API/MetricsController.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public function prometheusAction(): Response
7979
->select('t', 'u')
8080
->from(Team::class, 't')
8181
->leftJoin('t.users', 'u')
82-
->join('t.category', 'cat')
82+
// TODO: category type
83+
->join('t.categories', 'cat')
8384
->andWhere('cat.visible = true')
8485
->getQuery()
8586
->getResult();
@@ -89,7 +90,8 @@ public function prometheusAction(): Response
8990
->select('u')
9091
->from(User::class, 'u')
9192
->leftJoin('u.team', 't')
92-
->join('t.category', 'cat')
93+
// TODO: category type
94+
->join('t.categories', 'cat')
9395
->andWhere('cat.visible = true')
9496
->getQuery()
9597
->getResult();
@@ -134,7 +136,8 @@ public function prometheusAction(): Response
134136
->from(Team::class, 't')
135137
->leftJoin('t.users', 'u')
136138
->leftJoin('t.contests', 'c')
137-
->join('t.category', 'cat')
139+
// TODO: category type
140+
->join('t.categories', 'cat')
138141
->leftJoin('cat.contests', 'cc')
139142
->andWhere('c.cid = :cid OR cc.cid = :cid')
140143
->andWhere('cat.visible = true')
@@ -154,7 +157,8 @@ public function prometheusAction(): Response
154157
->from(User::class, 'u')
155158
->leftJoin('u.team', 't')
156159
->leftJoin('t.contests', 'c')
157-
->join('t.category', 'cat')
160+
// TODO: category type
161+
->join('t.categories', 'cat')
158162
->leftJoin('cat.contests', 'cc')
159163
->andWhere('c.cid = :cid OR cc.cid = :cid')
160164
->andWhere('cat.visible = true')
@@ -227,7 +231,8 @@ public function prometheusAction(): Response
227231
->join('b.submission', 's')
228232
->join('s.contest', 'c')
229233
->join('s.team', 't')
230-
->join('t.category', 'cat')
234+
// TODO: category type
235+
->join('t.categories', 'cat')
231236
->andWhere('b.done = false')
232237
->andWhere('c.cid = :cid')
233238
->andWhere('cat.visible = true')

webapp/src/Controller/API/ScoreboardController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function getScoreboardAction(
171171
$scoreIsInSeconds = (bool)$this->config->get('score_in_seconds');
172172

173173
foreach ($scoreboard->getScores() as $teamScore) {
174-
if ($teamScore->team->getCategory()->getSortorder() !== $sortorder) {
174+
if ($teamScore->team->getSortorder() !== $sortorder) {
175175
continue;
176176
}
177177

webapp/src/Controller/API/SubmissionController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ protected function getQueryBuilder(Request $request): QueryBuilder
462462
if (!$this->dj->checkrole('api_reader') &&
463463
!$this->dj->checkrole('judgehost')) {
464464
$queryBuilder
465-
->join('t.category', 'cat');
465+
// TODO: category type
466+
->join('t.categories', 'cat');
466467
if ($this->dj->checkrole('team')) {
467468
$queryBuilder
468469
->andWhere('cat.visible = 1 OR s.team = :team')

webapp/src/Controller/API/TeamController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,15 @@ protected function getQueryBuilder(Request $request): QueryBuilder
305305
$queryBuilder = $this->em->createQueryBuilder()
306306
->from(Team::class, 't')
307307
->leftJoin('t.affiliation', 'ta')
308-
->leftJoin('t.category', 'tc')
308+
// TODO: category type
309+
->leftJoin('t.categories', 'tc')
309310
->leftJoin('t.contests', 'c')
310311
->leftJoin('tc.contests', 'cc')
311312
->select('t, ta');
312313

313314
if ($request->query->has('category')) {
314315
$queryBuilder
315-
->andWhere('t.category = :category')
316+
->andWhere('tc.categoryid = :category')
316317
->setParameter('category', $request->query->get('category'));
317318
}
318319

webapp/src/Controller/Jury/ContestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function indexAction(Request $request): Response
216216
->select('COUNT(DISTINCT t.teamid)')
217217
->from(Team::class, 't')
218218
->leftJoin('t.contests', 'c')
219-
->join('t.category', 'cat')
219+
->join('t.categories', 'cat')
220220
->leftJoin('cat.contests', 'cc')
221221
->andWhere('c.cid = :cid OR cc.cid = :cid')
222222
->setParameter('cid', $contest->getCid())

webapp/src/Controller/Jury/ImportExportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ protected function getResultsHtml(
487487
'rank' => null,
488488
];
489489
foreach ($teams as $team) {
490-
if (!isset($categories[$team->getCategory()->getCategoryid()]) || $team->getCategory()->getSortorder() !== $sortOrder) {
490+
if ($team->getHidden() || $team->getSortorder() !== $sortOrder) {
491491
continue;
492492
}
493493

webapp/src/Controller/Jury/JudgeRemainingTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function judgeRemaining(int $contestId = -1, string $categoryId = '', str
8080
->select('j')
8181
->join('j.submission', 's')
8282
->join('s.team', 't')
83-
->join('t.category', 'tc')
83+
->join('t.categories', 'tc')
8484
->andWhere('j.valid = true')
8585
->andWhere('j.result != :compiler_error')
8686
->setParameter('compiler_error', 'compiler-error');

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ public function verifyAction(
11451145
if (!$judging->getContest()->isOpenToAllTeams()) {
11461146
$teamsQueryBuilder
11471147
->leftJoin('t.contests', 'c')
1148-
->join('t.category', 'cat')
1148+
->join('t.categories', 'cat')
11491149
->leftJoin('cat.contests', 'cc')
11501150
->andWhere('c.cid = :cid OR cc.cid = :cid')
11511151
->setParameter('cid', $judging->getContest()->getCid());

0 commit comments

Comments
 (0)