Skip to content

Commit 15aeae7

Browse files
committed
Balloon list: only add 'first in contest' if there is no earlier unjudged submission.
The 'first for problem' is already working correctly as it re-uses the corresponding scoreboard data. Fixes DOMjudge#2810.
1 parent 7c890e8 commit 15aeae7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

webapp/src/Service/BalloonService.php

+18
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,26 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array
141141
}
142142
// Keep overwriting this - in the end it'll
143143
// contain the ID of the first balloon in this contest.
144+
$submittime = $balloonsData[0]->getSubmission()->getSubmittime();
144145
$AWARD_BALLOONS['contest'] = $balloonsData[0]->getBalloonId();
145146
}
147+
$countBefore = $em->createQueryBuilder()
148+
->from(Judging::class, 'j')
149+
->leftJoin('j.submission', 's')
150+
->select('COUNT(s.submitid)')
151+
->where('s.contest = :cid')
152+
->andWhere('s.submittime < :submittime')
153+
->andWhere('s.valid = 1')
154+
->andWhere('j.valid = 1')
155+
->andWhere('j.result IS NULL')
156+
->setParameter('cid', $contest->getCid())
157+
->setParameter('submittime', $submittime)
158+
->getQuery()->getSingleScalarResult();
159+
if ($countBefore > 0) {
160+
// We don't have complete information about 'first in contest' yet as there are unjudged submissions that
161+
// could influence the result.
162+
$AWARD_BALLOONS['contest'] = -1;
163+
}
146164

147165
// Loop again to construct table.
148166
$balloons_table = [];

0 commit comments

Comments
 (0)