@@ -912,31 +912,28 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
912912 {
913913 $ judging = $ this ->em ->getRepository (Judging::class)->find ($ judgingId );
914914 if ($ judging ) {
915- $ this ->em ->wrapInTransaction (function () use ($ judging , $ judgehost ) {
916- /** @var JudgingRun $run */
917- foreach ($ judging ->getRuns () as $ run ) {
918- if ($ judgehost === null ) {
919- // This is coming from internal errors, reset the whole judging.
920- $ run ->getJudgetask ()
921- ->setValid (false );
922- continue ;
923- }
924-
925- // We do not have to touch any finished runs
926- if ($ run ->getRunresult () !== null ) {
927- continue ;
928- }
915+ $ q = $ this ->em ->createQueryBuilder ()
916+ ->update (JudgingRun::class, 'jr ' )
917+ ->join (JudgeTask::class, 'jt ' )
918+ ->andWhere ('jr.runresult IS NOT NULL ' )
919+ ->andWhere ('jr.judgingid = :judgingid ' )
920+ ->setParameter ('judgingid ' , $ judgingId );
929921
930- // For the other runs, we need to reset the judge task if it belongs to the current judgehost.
931- if ($ run ->getJudgetask ()->getJudgehost () && $ run ->getJudgetask ()->getJudgehost ()->getHostname () === $ judgehost ->getHostname ()) {
932- $ run ->getJudgetask ()
933- ->setJudgehost (null )
934- ->setStarttime (null );
935- }
936- }
922+ if ($ judgehost === null ) {
923+ // This is coming from internal errors, reset the whole judging.
924+ $ q ->set ('jt.valid ' , 0 );
925+ } else {
926+ $ q ->andWhere ('jr.run_result IS NOT NULL ' )
927+ ->join (JudgeHost::class, 'jh ' )
928+ ->set ('jt.judgehostid ' , ':judgehostid ' )
929+ ->set ('jt.starttime ' , ':starttime ' )
930+ ->setParameter ('judgehostid ' , null )
931+ ->setParameter ('starttime ' , null )
932+ ->andWhere ('jh.hostname = :judgehost ' )
933+ ->setParameter ('judgehost ' , $ judgehost ->getHostname ());
934+ }
937935
938- $ this ->em ->flush ();
939- });
936+ $ q ->getQuery ()->execute ();
940937
941938 if ($ judgehost === null ) {
942939 // Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by
0 commit comments