From 15aeae73df2bebc02c36cf295d4c8f8c7376507e Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Thu, 21 Nov 2024 11:16:34 +0100 Subject: [PATCH] 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 #2810. --- webapp/src/Service/BalloonService.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/webapp/src/Service/BalloonService.php b/webapp/src/Service/BalloonService.php index ff93e2fddf..116e5761f6 100644 --- a/webapp/src/Service/BalloonService.php +++ b/webapp/src/Service/BalloonService.php @@ -141,8 +141,26 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array } // Keep overwriting this - in the end it'll // contain the ID of the first balloon in this contest. + $submittime = $balloonsData[0]->getSubmission()->getSubmittime(); $AWARD_BALLOONS['contest'] = $balloonsData[0]->getBalloonId(); } + $countBefore = $em->createQueryBuilder() + ->from(Judging::class, 'j') + ->leftJoin('j.submission', 's') + ->select('COUNT(s.submitid)') + ->where('s.contest = :cid') + ->andWhere('s.submittime < :submittime') + ->andWhere('s.valid = 1') + ->andWhere('j.valid = 1') + ->andWhere('j.result IS NULL') + ->setParameter('cid', $contest->getCid()) + ->setParameter('submittime', $submittime) + ->getQuery()->getSingleScalarResult(); + if ($countBefore > 0) { + // We don't have complete information about 'first in contest' yet as there are unjudged submissions that + // could influence the result. + $AWARD_BALLOONS['contest'] = -1; + } // Loop again to construct table. $balloons_table = [];