Initial commit
This commit is contained in:
36
app/Services/Evaluation/ClaimedRunResolver.php
Normal file
36
app/Services/Evaluation/ClaimedRunResolver.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user