Initial commit
This commit is contained in:
56
app/Jobs/DispatchScoreJobsJob.php
Normal file
56
app/Jobs/DispatchScoreJobsJob.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user