@@ -909,31 +909,26 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
909909 {
910910 $ judging$ this em ->getRepository (Judging::class)->find ($ judgingId
911911 if  ($ judging
912-  $ this em ->wrapInTransaction (function  () use  ($ judging$ judgehost
913-  /** @var JudgingRun $run */ 
914-  foreach  ($ judginggetRuns () as  $ run
915-  if  ($ judgehostnull ) {
916-  // This is coming from internal errors, reset the whole judging. 
917-  $ rungetJudgetask ()
918-  ->setValid (false );
919-  continue ;
920-  }
921- 922-  // We do not have to touch any finished runs 
923-  if  ($ rungetRunresult () !== null ) {
924-  continue ;
925-  }
912+  $ q$ this em ->createQueryBuilder ()
913+  ->update (JudgingRun::class)
914+  ->join (JudgeTask::class, 'jt ' )
915+  ->where ('jr.runresult IS NOT NULL ' )
916+  ->where ('jr.judgingid = :judgingid ' )
917+  ->setParameter ('judgingid ' , $ judgingId
926918
927-  // For the other runs, we need to reset the judge task if it belongs to the current judgehost. 
928-  if  ($ rungetJudgetask ()->getJudgehost () && $ rungetJudgetask ()->getJudgehost ()->getHostname () === $ judgehostgetHostname ()) {
929-  $ rungetJudgetask ()
930-  ->setJudgehost (null )
931-  ->setStarttime (null );
932-  }
933-  }
919+  if  ($ judgehostnull ) {
920+  // This is coming from internal errors, reset the whole judging. 
921+  $ qset ('jt.valid ' , 0 );
922+  } else  {
923+  $ qandWhere ('jr.run_result IS NOT NULL ' )
924+  ->join (JudgeHost::class, 'jh ' )
925+  ->set ('jt.judgehostid ' , null )
926+  ->set ('jt.starttime ' , null )
927+  ->andWhere ('jh.hostname = :judgehost ' )
928+  ->setParameter ('judgehost ' , $ judgehostgetHostname ());
929+  }
934930
935-  $ this em ->flush ();
936-  });
931+  $ qgetQuery ()->execute ();
937932
938933 if  ($ judgehostnull ) {
939934 // Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by 
0 commit comments