Skip to content

Commit ac60eca

Browse files
committed
Fix progress display of rejudgings that apply automatically.
Fixes #2141.
1 parent f740f73 commit ac60eca

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

webapp/src/Service/RejudgingService.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,27 @@ public function finishRejudging(Rejudging $rejudging, string $action, ?callable
390390
public function calculateTodo(Rejudging $rejudging): array
391391
{
392392
// Make sure we have the most recent data. This is necessary to
393-
// guarantee that repeated rejugdings are scheduled correctly.
393+
// guarantee that repeated rejudgings are scheduled correctly.
394394
$this->em->flush();
395395

396-
$todo = $this->em->createQueryBuilder()
397-
->from(Submission::class, 's')
398-
->select('COUNT(s)')
399-
->andWhere('s.rejudging = :rejudging')
400-
->setParameter('rejudging', $rejudging)
401-
->getQuery()
402-
->getSingleScalarResult();
403-
404-
$done = $this->em->createQueryBuilder()
396+
$queryBuilder = $this->em->createQueryBuilder()
405397
->from(Judging::class, 'j')
406398
->select('COUNT(j)')
407399
->andWhere('j.rejudging = :rejudging')
400+
->setParameter('rejudging', $rejudging);
401+
402+
$clonedQueryBuilder = clone $queryBuilder;
403+
404+
$todo = $queryBuilder
405+
->andWhere('j.endtime IS NULL')
406+
->getQuery()
407+
->getSingleScalarResult();
408+
409+
$done = $clonedQueryBuilder
408410
->andWhere('j.endtime IS NOT NULL')
409-
// This is necessary for rejudgings which apply automatically.
410-
// We remove the association of the submission with the rejudging,
411-
// but not the one of the judging with the rejudging for accounting reasons.
412-
->andWhere('j.valid = 0')
413-
->setParameter('rejudging', $rejudging)
414411
->getQuery()
415412
->getSingleScalarResult();
416413

417-
$todo -= $done;
418414
return ['todo' => $todo, 'done' => $done];
419415
}
420416
}

0 commit comments

Comments
 (0)