@@ -390,31 +390,27 @@ public function finishRejudging(Rejudging $rejudging, string $action, ?callable
390
390
public function calculateTodo (Rejudging $ rejudging ): array
391
391
{
392
392
// 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.
394
394
$ this ->em ->flush ();
395
395
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 ()
405
397
->from (Judging::class, 'j ' )
406
398
->select ('COUNT(j) ' )
407
399
->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
408
410
->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 )
414
411
->getQuery ()
415
412
->getSingleScalarResult ();
416
413
417
- $ todo -= $ done ;
418
414
return ['todo ' => $ todo , 'done ' => $ done ];
419
415
}
420
416
}
0 commit comments