@@ -898,31 +898,26 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
898898 {
899899 $ judging = $ this ->em ->getRepository (Judging::class)->find ($ judgingId );
900900 if ($ judging ) {
901- $ this ->em ->wrapInTransaction (function () use ($ judging , $ judgehost ) {
902- /** @var JudgingRun $run */
903- foreach ($ judging ->getRuns () as $ run ) {
904- if ($ judgehost === null ) {
905- // This is coming from internal errors, reset the whole judging.
906- $ run ->getJudgetask ()
907- ->setValid (false );
908- continue ;
909- }
910-
911- // We do not have to touch any finished runs
912- if ($ run ->getRunresult () !== null ) {
913- continue ;
914- }
901+ $ q = $ this ->em ->createQueryBuilder ()
902+ ->update (JudgingRun::class)
903+ ->join (JudgeTask::class, 'jt ' )
904+ ->where ('jr.runresult IS NOT NULL ' )
905+ ->where ('jr.judgingid = :judgingid ' )
906+ ->setParameter ('judgingid ' , $ judgingId );
915907
916- // For the other runs, we need to reset the judge task if it belongs to the current judgehost.
917- if ($ run ->getJudgetask ()->getJudgehost () && $ run ->getJudgetask ()->getJudgehost ()->getHostname () === $ judgehost ->getHostname ()) {
918- $ run ->getJudgetask ()
919- ->setJudgehost (null )
920- ->setStarttime (null );
921- }
922- }
908+ if ($ judgehost === null ) {
909+ // This is coming from internal errors, reset the whole judging.
910+ $ q ->set ('jt.valid ' , 0 );
911+ } else {
912+ $ q ->andWhere ('jr.run_result IS NOT NULL ' )
913+ ->join (JudgeHost::class, 'jh ' )
914+ ->set ('jt.judgehostid ' , null )
915+ ->set ('jt.starttime ' , null )
916+ ->andWhere ('jh.hostname = :judgehost ' )
917+ ->setParameter ('judgehost ' , $ judgehost ->getHostname ());
918+ }
923919
924- $ this ->em ->flush ();
925- });
920+ $ q ->getQuery ()->execute ();
926921
927922 if ($ judgehost === null ) {
928923 // Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by
0 commit comments