From fd3855a775c7fc4e4af4134f9750d93de0fde7ec Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 26 Jun 2025 10:07:51 -0500 Subject: [PATCH] Add console command to force recalculation of scores --- .../ForceRecalculateTotalScores.php | 16 +++++++++ app/Actions/Tabulation/TotalEntryScores.php | 7 ++-- app/Console/Commands/RecalculateScores.php | 35 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 app/Actions/Tabulation/ForceRecalculateTotalScores.php create mode 100644 app/Console/Commands/RecalculateScores.php diff --git a/app/Actions/Tabulation/ForceRecalculateTotalScores.php b/app/Actions/Tabulation/ForceRecalculateTotalScores.php new file mode 100644 index 0000000..d5c6bde --- /dev/null +++ b/app/Actions/Tabulation/ForceRecalculateTotalScores.php @@ -0,0 +1,16 @@ +advancement_subscore_totals = $total_advancement_subscores; // pull in bonus scores - $bonusScores = BonusScore::where('entry_id', $entry->id)->sum('score'); - $newTotaledScore->bonus_score = $bonusScores; + $bonusScores = BonusScore::where('entry_id', $entry->id) + ->selectRaw('SUM(score) as total') + ->value('total'); + + $newTotaledScore->bonus_total = $bonusScores; $newTotaledScore->save(); } diff --git a/app/Console/Commands/RecalculateScores.php b/app/Console/Commands/RecalculateScores.php new file mode 100644 index 0000000..acc43ad --- /dev/null +++ b/app/Console/Commands/RecalculateScores.php @@ -0,0 +1,35 @@ +info('Starting score recalculation...'); + + $action(); + + $this->info('Score recalculation completed successfully.'); + } +}