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