From 33bca1cfdf140c4094746d1aab2c0767c5a63249 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Sun, 15 Jun 2025 14:31:52 -0500 Subject: [PATCH] Avoid division by zero errors. --- app/Actions/Tabulation/TotalEntryScores.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Actions/Tabulation/TotalEntryScores.php b/app/Actions/Tabulation/TotalEntryScores.php index 241a9af..448e650 100644 --- a/app/Actions/Tabulation/TotalEntryScores.php +++ b/app/Actions/Tabulation/TotalEntryScores.php @@ -30,7 +30,12 @@ class TotalEntryScores $newTotaledScore->entry_id = $entry->id; // deal with seating scores + // TODO: Consider a rewrite to pull the scoreSheets from the entry model so they may be preloaded $scoreSheets = ScoreSheet::where('entry_id', $entry->id)->orderBy('seating_total', 'desc')->get(); + // bail out if there are no score sheets + if ($scoreSheets->count() == 0) { + return; + } if (auditionSetting('olympic_scoring' && $scoreSheets->count() > 2)) { // under olympic scoring, drop the first and last element $scoreSheets->shift();