From 1c3bb39805646adefc45c2aa02d951333ba6ba77 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 20 Nov 2025 11:21:17 -0600 Subject: [PATCH] Add console command to force recalculation of judge totals --- .../RecalculateJudgeTotalsCommand.php | 41 +++++++++++++++++++ ...eScores.php => RecalculateTotalScores.php} | 4 +- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 app/Console/Commands/RecalculateJudgeTotalsCommand.php rename app/Console/Commands/{RecalculateScores.php => RecalculateTotalScores.php} (86%) 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.