@@ -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 ($ judging ->getRuns () as $ run ) {
915- if ($ judgehost === null ) {
916- // This is coming from internal errors, reset the whole judging.
917- $ run ->getJudgetask ()
918- ->setValid (false );
919- continue ;
920- }
921-
922- // We do not have to touch any finished runs
923- if ($ run ->getRunresult () !== 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 ($ run ->getJudgetask ()->getJudgehost () && $ run ->getJudgetask ()->getJudgehost ()->getHostname () === $ judgehost ->getHostname ()) {
929- $ run ->getJudgetask ()
930- ->setJudgehost (null )
931- ->setStarttime (null );
932- }
933- }
919+ if ($ judgehost === null ) {
920+ // This is coming from internal errors, reset the whole judging.
921+ $ q ->set ('jt.valid ' , 0 );
922+ } else {
923+ $ q ->andWhere ('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 ' , $ judgehost ->getHostname ());
929+ }
934930
935- $ this ->em ->flush ();
936- });
931+ $ q ->getQuery ()->execute ();
937932
938933 if ($ judgehost === null ) {
939934 // Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by
0 commit comments