Files
vkv/app/Jobs/DispatchScoreJobsJob.php
Zdeněk Burda 41e3ce6f25 Initial commit
2026-01-09 21:26:40 +01:00

57 lines
1.5 KiB
PHP

<?php
namespace App\Jobs;
use App\Models\EvaluationRun;
use App\Services\Evaluation\EvaluationCoordinator;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Throwable;
/**
* Job: DispatchScoreJobsJob
*
* Připraví batch scoring jobů a nastaví korektní progress pro krok score.
*/
class DispatchScoreJobsJob implements ShouldQueue
{
use Queueable;
public int $tries = 2;
public array $backoff = [30];
public function __construct(
protected int $evaluationRunId
) {
}
public function handle(): void
{
$run = EvaluationRun::find($this->evaluationRunId);
if (! $run || $run->isCanceled()) {
return;
}
$coordinator = app(EvaluationCoordinator::class);
$coordinator->eventInfo($run, 'Dispatch score: krok spuštěn.', [
'step' => 'dispatch_score',
'round_id' => $run->round_id,
]);
try {
$coordinator->dispatchStep($run, 'score');
$coordinator->eventInfo($run, 'Dispatch score: krok dokončen.', [
'step' => 'dispatch_score',
'round_id' => $run->round_id,
]);
} catch (Throwable $e) {
$coordinator->eventError($run, 'Dispatch score: krok selhal.', [
'step' => 'dispatch_score',
'round_id' => $run->round_id,
'error' => $e->getMessage(),
]);
throw $e;
}
}
}