37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Evaluation;
|
|
|
|
use App\Models\EvaluationRun;
|
|
|
|
class ClaimedRunResolver
|
|
{
|
|
public static function forRound(int $roundId): EvaluationRun
|
|
{
|
|
// Preferujeme poslední CLAIMED run, aby projekce zůstala konzistentní.
|
|
$run = EvaluationRun::where('round_id', $roundId)
|
|
->where('rules_version', 'CLAIMED')
|
|
->orderByDesc('created_at')
|
|
->first();
|
|
|
|
if ($run) {
|
|
return $run;
|
|
}
|
|
|
|
return self::createNewForRound($roundId);
|
|
}
|
|
|
|
public static function createNewForRound(int $roundId, ?int $createdByUserId = null): EvaluationRun
|
|
{
|
|
// CLAIMED run je projekce deklarovaných výsledků, ne finální vyhodnocení.
|
|
return EvaluationRun::create([
|
|
'round_id' => $roundId,
|
|
'rules_version' => 'CLAIMED',
|
|
'name' => 'Deklarované výsledky',
|
|
'is_official' => false,
|
|
'status' => 'PENDING',
|
|
'created_by_user_id' => $createdByUserId,
|
|
]);
|
|
}
|
|
}
|