Avoid division by zero errors.

This commit is contained in:
Matt Young 2025-06-15 14:31:52 -05:00
parent 49b609e9b7
commit 33bca1cfdf
1 changed files with 5 additions and 0 deletions

View File

@ -30,7 +30,12 @@ class TotalEntryScores
$newTotaledScore->entry_id = $entry->id; $newTotaledScore->entry_id = $entry->id;
// deal with seating scores // 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(); $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)) { if (auditionSetting('olympic_scoring' && $scoreSheets->count() > 2)) {
// under olympic scoring, drop the first and last element // under olympic scoring, drop the first and last element
$scoreSheets->shift(); $scoreSheets->shift();