Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion webapp/src/Controller/API/BalloonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function listAction(
category: $b['data']['category'],
categoryid: $b['data']['categoryid'],
total: $b['data']['total'],
awards: $b['data']['awards'],
done: $b['data']['done'],
);
}
Expand Down
1 change: 0 additions & 1 deletion webapp/src/DataTransferObject/Balloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function __construct(
public readonly ?int $categoryid,
#[Serializer\Type('array<string, App\Entity\ContestProblem>')]
public readonly array $total,
public readonly string $awards,
public readonly bool $done,
) {}
}
31 changes: 3 additions & 28 deletions webapp/src/Service/BalloonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function updateBalloons(
* @return array<array{data: array{balloonid: int, time: string, problem: string, contestproblem: ContestProblem,
* team: Team, teamid: int, location: string|null, affiliation: string|null,
* affiliationid: int, category: string, categoryid: int, total: array<string, ContestProblem>,
* awards: string, done: bool}}>
* done: bool}}>
*/
public function collectBalloonTable(Contest $contest, bool $todo = false): array
{
Expand All @@ -97,13 +97,6 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
$freezetime = $contest->getFreezeTime();
}

// Build a list of teams and the problems they solved first.
$firstSolved = $em->getRepository(ScoreCache::class)->findBy(['is_first_to_solve' => 1]);
$firstSolvers = [];
foreach ($firstSolved as $scoreCache) {
$firstSolvers[$scoreCache->getTeam()->getTeamId()][] = $scoreCache->getProblem()->getProbid();
}

$query = $em->createQueryBuilder()
->select('b', 's.submittime', 'p.probid',
't.teamid', 's', 't', 't.location',
Expand All @@ -125,23 +118,14 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
->addOrderBy('s.submittime', 'DESC');

$balloons = $query->getQuery()->getResult();
// Loop once over the results to get totals and awards.
$TOTAL_BALLOONS = $AWARD_BALLOONS = [];
// Loop once over the results to get totals.
$TOTAL_BALLOONS = [];
foreach ($balloons as $balloonsData) {
if ($balloonsData['color'] === null) {
continue;
}

$TOTAL_BALLOONS[$balloonsData['teamid']][$balloonsData['probshortname']] = $balloonsData[0]->getSubmission()->getContestProblem();

// Keep a list of balloons that were first to solve this problem;
// can be multiple, one for each sortorder.
if (in_array($balloonsData['probid'], $firstSolvers[$balloonsData['teamid']] ?? [], true)) {
$AWARD_BALLOONS['problem'][$balloonsData['probid']][] = $balloonsData[0]->getBalloonId();
}
// Keep overwriting this - in the end it'll
// contain the ID of the first balloon in this contest.
$AWARD_BALLOONS['contest'] = $balloonsData[0]->getBalloonId();
}

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

$comments = [];
if ($AWARD_BALLOONS['contest'] == $balloonId) {
$comments[] = 'first in contest';
} elseif (isset($AWARD_BALLOONS['problem'][$balloonsData['probid']])
&& in_array($balloonId, $AWARD_BALLOONS['problem'][$balloonsData['probid']], true)) {
$comments[] = 'first for problem';
}

$balloondata['awards'] = implode('; ', $comments);
$balloondata['done'] = $done;

$balloons_table[] = [
Expand Down
2 changes: 0 additions & 2 deletions webapp/templates/jury/partials/balloon_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<th scope="col">location</th>
<th scope="col">category</th>
<th scope="col">total</th>
<th scope="col">awards</th>
<th scope="col"></th>
</tr>
</thead>
Expand Down Expand Up @@ -47,7 +46,6 @@
{{ totalballoon | problemBadge }}&nbsp;
{%- endfor -%}
</td>
<td>{{ balloon.data.awards }}</td>
<td>
{%- if not balloon.data.done -%}
{%- set link = path('jury_balloons_setdone', {balloonId: balloon.data.balloonid}) %}
Expand Down
4 changes: 2 additions & 2 deletions webapp/tests/Unit/Controller/API/BalloonsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testBalloonsNoJudgings(): void

public function testMarkAsDone(): void
{
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U', 'awards'=>'first in contest'];
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U'];
$contestId = $this->getUnitContestId();
$url = "/contests/$contestId/balloons?todo=1";
$this->loadFixtures([BalloonCorrectSubmissionFixture::class,BalloonUserFixture::class]);
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testMarkInvalidBalloonAsDone(): void
public function testMarkAsDoneWrongContest(): void
{
// BalloonIDs are global so they can be marked done against other contests.
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U', 'awards'=>'first in contest'];
$expectedBalloon = ['team'=>'t2: Example teamname', 'problem'=>'U'];
$contestId = $this->getUnitContestId();
$url = "/contests/$contestId/balloons?todo=1";
$this->loadFixtures([BalloonCorrectSubmissionFixture::class,BalloonUserFixture::class]);
Expand Down
Loading