When appropriate, include bonus score in ranking entrie. Show if an entry has bonus scores when appropriate.

This commit is contained in:
Matt Young 2025-06-26 10:22:59 -05:00
parent fd3855a775
commit 04cfde353e
2 changed files with 19 additions and 4 deletions

View File

@ -42,13 +42,19 @@ class RankAuditionEntries
private function get_seating_ranks(Audition $audition): Collection private function get_seating_ranks(Audition $audition): Collection
{ {
if ($audition->bonusScore()->count() > 0) {
$totalColumn = 'seating_total_with_bonus';
} else {
$totalColumn = 'seating_total';
}
$sortedEntries = $audition->entries() $sortedEntries = $audition->entries()
->whereHas('totalScore') ->whereHas('totalScore')
->with('totalScore') ->with('totalScore')
->with('student.school') ->with('student.school')
->with('audition') ->with('audition')
->join('entry_total_scores', 'entries.id', '=', 'entry_total_scores.entry_id') ->join('entry_total_scores', 'entries.id', '=', 'entry_total_scores.entry_id')
->orderBy('entry_total_scores.seating_total', 'desc') ->orderBy('entry_total_scores.'.$totalColumn, 'desc')
->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[0]"), -999999) DESC') ->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[0]"), -999999) DESC')
->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[1]"), -999999) DESC') ->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[1]"), -999999) DESC')
->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[2]"), -999999) DESC') ->orderByRaw('COALESCE(JSON_EXTRACT(entry_total_scores.seating_subscore_totals, "$[2]"), -999999) DESC')

View File

@ -17,8 +17,7 @@
@if($audition->bonusScore()->count() > 0) @if($audition->bonusScore()->count() > 0)
<br> <br>
<div class="display: flex"> <div class="display: flex">
<x-icons.checkmark color="green"/> <span class="text-yellow-500">No Bonus Score</span>
Has Bonus
</div> </div>
@endif @endif
</x-table.th> </x-table.th>
@ -65,7 +64,17 @@
</x-table.td> </x-table.td>
<x-table.td class="align-top">{{ $entry->totalScore->seating_total }}</x-table.td> <x-table.td class="align-top">
@if($audition->bonusScore()->count() > 0)
@if($entry->totalScore->bonus_total)
<span>{{ $entry->totalScore->seating_total_with_bonus }}</span>
@else
<span class="text-yellow-500">{{ $entry->totalScore->seating_total_with_bonus }}</span>
@endif
@else
{{ $entry->totalScore->seating_total }}
@endif
</x-table.td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>