evaluationRunId); if (! $run || $run->isCanceled()) { return; } $coordinator = new EvaluationCoordinator(); $coordinator->eventInfo($run, 'Dispatch unpaired: krok spuštěn.', [ 'step' => 'dispatch_unpaired', 'round_id' => $run->round_id, ]); try { $buckets = WorkingQso::where('evaluation_run_id', $run->id) ->whereNotNull('rcall_norm') ->distinct() ->get(['band_id', 'rcall_norm']); $jobs = []; foreach ($buckets as $bucket) { $jobs[] = new UnpairedClassificationBucketJob( $run->id, $bucket->band_id !== null ? (int) $bucket->band_id : null, $bucket->rcall_norm ); } $run->refresh(); $progressDone = (int) $run->progress_done; $progressTotal = $progressDone + count($jobs) + 1; $run->update([ 'progress_total' => $progressTotal, 'progress_done' => $progressDone, ]); $next = function () use ($run) { Bus::chain([ new DuplicateResolutionJob($run->id), new PauseEvaluationRunJob( $run->id, 'WAITING_REVIEW_MATCH', 'waiting_review_match', 'Čeká na kontrolu matchingu.' ), ])->onQueue('evaluation')->dispatch(); }; if (! $jobs) { $next(); return; } $batch = Bus::batch($jobs) ->then($next) ->onQueue('evaluation') ->dispatch(); $run->update(['batch_id' => $batch->id]); $coordinator->eventInfo($run, 'Dispatch unpaired: krok dokončen.', [ 'step' => 'dispatch_unpaired', 'round_id' => $run->round_id, ]); } catch (Throwable $e) { $coordinator->eventError($run, 'Dispatch unpaired: krok selhal.', [ 'step' => 'dispatch_unpaired', 'round_id' => $run->round_id, 'error' => $e->getMessage(), ]); throw $e; } } }