evaluationRunId); if (! $run || $run->isCanceled()) { return; } $coordinator = new EvaluationCoordinator(); try { $coordinator->eventInfo($run, 'Aggregate: krok spuštěn.', [ 'step' => 'aggregate', 'round_id' => $run->round_id, ]); $logIds = LogResult::where('evaluation_run_id', $run->id) ->pluck('log_id') ->all(); $run->update([ 'status' => 'RUNNING', 'current_step' => 'aggregate', 'progress_total' => count($logIds), 'progress_done' => 0, ]); $jobs = []; foreach ($logIds as $logId) { $jobs[] = new AggregateLogResultsJob($run->id, (int) $logId); } $next = function () use ($run) { Bus::chain([ new ApplyLogOverridesJob($run->id), new RecalculateOfficialRanksJob($run->id), new PauseEvaluationRunJob( $run->id, 'WAITING_REVIEW_SCORE', 'waiting_review_score', 'Čeká na kontrolu skóre.' ), ])->onQueue('evaluation')->dispatch(); }; if (! $jobs) { $next(); return; } $batch = Bus::batch($jobs) ->then($next) ->onQueue('evaluation') ->dispatch(); $run->update(['batch_id' => $batch->id]); } catch (Throwable $e) { $coordinator->eventError($run, 'Aggregate: krok selhal.', [ 'step' => 'aggregate', 'round_id' => $run->round_id, 'error' => $e->getMessage(), ]); throw $e; } } }