Skip to content

Commit 153a637

Browse files
committed
Remove first to solve in problem/contest from balloon service.
Fixes #3023. This is not worth the complexity to get it right under all edge cases. Parts of our discussion was recorded in #2810
1 parent e913d7c commit 153a637

File tree

5 files changed

+5
-34
lines changed

5 files changed

+5
-34
lines changed

webapp/src/Controller/API/BalloonController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function listAction(
7373
category: $b['data']['category'],
7474
categoryid: $b['data']['categoryid'],
7575
total: $b['data']['total'],
76-
awards: $b['data']['awards'],
7776
done: $b['data']['done'],
7877
);
7978
}

webapp/src/DataTransferObject/Balloon.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public function __construct(
2424
public readonly ?int $categoryid,
2525
#[Serializer\Type('array<string, App\Entity\ContestProblem>')]
2626
public readonly array $total,
27-
public readonly string $awards,
2827
public readonly bool $done,
2928
) {}
3029
}

webapp/src/Service/BalloonService.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function updateBalloons(
8787
* @return array<array{data: array{balloonid: int, time: string, problem: string, contestproblem: ContestProblem,
8888
* team: Team, teamid: int, location: string|null, affiliation: string|null,
8989
* affiliationid: int, category: string, categoryid: int, total: array<string, ContestProblem>,
90-
* awards: string, done: bool}}>
90+
* done: bool}}>
9191
*/
9292
public function collectBalloonTable(Contest $contest, bool $todo = false): array
9393
{
@@ -97,13 +97,6 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
9797
$freezetime = $contest->getFreezeTime();
9898
}
9999

100-
// Build a list of teams and the problems they solved first.
101-
$firstSolved = $em->getRepository(ScoreCache::class)->findBy(['is_first_to_solve' => 1]);
102-
$firstSolvers = [];
103-
foreach ($firstSolved as $scoreCache) {
104-
$firstSolvers[$scoreCache->getTeam()->getTeamId()][] = $scoreCache->getProblem()->getProbid();
105-
}
106-
107100
$query = $em->createQueryBuilder()
108101
->select('b', 's.submittime', 'p.probid',
109102
't.teamid', 's', 't', 't.location',
@@ -125,23 +118,14 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
125118
->addOrderBy('s.submittime', 'DESC');
126119

127120
$balloons = $query->getQuery()->getResult();
128-
// Loop once over the results to get totals and awards.
129-
$TOTAL_BALLOONS = $AWARD_BALLOONS = [];
121+
// Loop once over the results to get totals.
122+
$TOTAL_BALLOONS = [];
130123
foreach ($balloons as $balloonsData) {
131124
if ($balloonsData['color'] === null) {
132125
continue;
133126
}
134127

135128
$TOTAL_BALLOONS[$balloonsData['teamid']][$balloonsData['probshortname']] = $balloonsData[0]->getSubmission()->getContestProblem();
136-
137-
// Keep a list of balloons that were first to solve this problem;
138-
// can be multiple, one for each sortorder.
139-
if (in_array($balloonsData['probid'], $firstSolvers[$balloonsData['teamid']] ?? [], true)) {
140-
$AWARD_BALLOONS['problem'][$balloonsData['probid']][] = $balloonsData[0]->getBalloonId();
141-
}
142-
// Keep overwriting this - in the end it'll
143-
// contain the ID of the first balloon in this contest.
144-
$AWARD_BALLOONS['contest'] = $balloonsData[0]->getBalloonId();
145129
}
146130

147131
// Loop again to construct table.
@@ -182,15 +166,6 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
182166
ksort($TOTAL_BALLOONS[$balloonsData['teamid']]);
183167
$balloondata['total'] = $TOTAL_BALLOONS[$balloonsData['teamid']];
184168

185-
$comments = [];
186-
if ($AWARD_BALLOONS['contest'] == $balloonId) {
187-
$comments[] = 'first in contest';
188-
} elseif (isset($AWARD_BALLOONS['problem'][$balloonsData['probid']])
189-
&& in_array($balloonId, $AWARD_BALLOONS['problem'][$balloonsData['probid']], true)) {
190-
$comments[] = 'first for problem';
191-
}
192-
193-
$balloondata['awards'] = implode('; ', $comments);
194169
$balloondata['done'] = $done;
195170

196171
$balloons_table[] = [

webapp/templates/jury/partials/balloon_list.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<th scope="col">location</th>
1717
<th scope="col">category</th>
1818
<th scope="col">total</th>
19-
<th scope="col">awards</th>
2019
<th scope="col"></th>
2120
</tr>
2221
</thead>
@@ -47,7 +46,6 @@
4746
{{ totalballoon | problemBadge }}&nbsp;
4847
{%- endfor -%}
4948
</td>
50-
<td>{{ balloon.data.awards }}</td>
5149
<td>
5250
{%- if not balloon.data.done -%}
5351
{%- set link = path('jury_balloons_setdone', {balloonId: balloon.data.balloonid}) %}

webapp/tests/Unit/Controller/API/BalloonsControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testBalloonsNoJudgings(): void
3737

3838
public function testMarkAsDone(): void
3939
{
40-
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U', 'awards'=>'first in contest'];
40+
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U'];
4141
$contestId = $this->getUnitContestId();
4242
$url = "/contests/$contestId/balloons?todo=1";
4343
$this->loadFixtures([BalloonCorrectSubmissionFixture::class,BalloonUserFixture::class]);
@@ -70,7 +70,7 @@ public function testMarkInvalidBalloonAsDone(): void
7070
public function testMarkAsDoneWrongContest(): void
7171
{
7272
// BalloonIDs are global so they can be marked done against other contests.
73-
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U', 'awards'=>'first in contest'];
73+
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U'];
7474
$contestId = $this->getUnitContestId();
7575
$url = "/contests/$contestId/balloons?todo=1";
7676
$this->loadFixtures([BalloonCorrectSubmissionFixture::class,BalloonUserFixture::class]);

0 commit comments

Comments
 (0)