diff --git a/app/Console/Commands/RecalculateJudgeTotalsCommand.php b/app/Console/Commands/RecalculateJudgeTotalsCommand.php new file mode 100644 index 0000000..75ed376 --- /dev/null +++ b/app/Console/Commands/RecalculateJudgeTotalsCommand.php @@ -0,0 +1,41 @@ +info('Starting score recalculation...'); + $scoreSheets = ScoreSheet::all(); + foreach ($scoreSheets as $scoreSheet) { + if ($scoreSheet->entry->audition->hasFlag('seats_published')) { + continue; + } + $this->recalculate($scoreSheet); + } + + $this->info('Score recalculation completed successfully.'); + } + + private function recalculate(ScoreSheet|int $scoreSheet): void + { + if (is_int($scoreSheet)) { + $scoreSheet = ScoreSheet::findOrFail($scoreSheet); + } + $scribe = app()->make(EnterScore::class); + $scoreSubmission = []; + foreach ($scoreSheet->subscores as $subscore) { + $scoreSubmission[$subscore['subscore_id']] = $subscore['score']; + } + $scribe($scoreSheet->judge, $scoreSheet->entry, $scoreSubmission, $scoreSheet); + } +} diff --git a/app/Console/Commands/RecalculateScores.php b/app/Console/Commands/RecalculateTotalScores.php similarity index 86% rename from app/Console/Commands/RecalculateScores.php rename to app/Console/Commands/RecalculateTotalScores.php index d7e0ded..a2b61ea 100644 --- a/app/Console/Commands/RecalculateScores.php +++ b/app/Console/Commands/RecalculateTotalScores.php @@ -8,14 +8,14 @@ use Illuminate\Console\Command; /** * @codeCoverageIgnore */ -class RecalculateScores extends Command +class RecalculateTotalScores extends Command { /** * The name and signature of the console command. * * @var string */ - protected $signature = 'audition:recalculate-scores'; + protected $signature = 'audition:recalculate-total-scores'; /** * The console command description.