Add advancement results to results page
This commit is contained in:
parent
4c7de27a54
commit
f067dfbe84
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Entry;
|
||||
use App\Models\Seat;
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\SeatingService;
|
||||
|
|
@ -28,6 +29,8 @@ class ResultsPage extends Controller
|
|||
$publishedAuditions = $this->auditionCacheService->getPublishedAuditions();
|
||||
$resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) {
|
||||
$seatList = [];
|
||||
// Load the $seatList in the form of $seatlist[audition_id] is an array of seats for that audition
|
||||
// each $seatList[audition_id][] will contain a string with ensemble and seat number and the student object filling it
|
||||
foreach ($publishedAuditions as $audition) {
|
||||
$seats = $this->seatingService->getSeatsForAudition($audition->id);
|
||||
$ensembles = $this->seatingService->getEnsemblesForEvent($audition->event_id);
|
||||
|
|
@ -48,6 +51,24 @@ class ResultsPage extends Controller
|
|||
return $seatList;
|
||||
});
|
||||
|
||||
return view('results.index', compact('publishedAuditions', 'resultsSeatList'));
|
||||
$publishedAdvancementAuditions = $this->auditionCacheService->getPublishedAdvancementAuditions();
|
||||
$resultsAdvancementList = Cache::rememberForever('resultsAdvancementList', function () use ($publishedAdvancementAuditions) {
|
||||
$qualifierList = [];
|
||||
foreach ($publishedAdvancementAuditions as $audition) {
|
||||
$qualifierList[$audition->id] = Entry::with('flags', 'student.school')
|
||||
->where('audition_id', $audition->id)
|
||||
->where('for_advancement', true)
|
||||
->get()->filter(function (Entry $entry) {
|
||||
return $entry->hasFlag('will_advance');
|
||||
})
|
||||
->sortBy(function (Entry $entry) {
|
||||
return $entry->student->full_name(true);
|
||||
});
|
||||
}
|
||||
|
||||
return $qualifierList;
|
||||
});
|
||||
|
||||
return view('results.index', compact('publishedAuditions', 'resultsSeatList', 'resultsAdvancementList', 'publishedAdvancementAuditions'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ class Student extends Model
|
|||
public function full_name(bool $last_name_first = false): string
|
||||
{
|
||||
if ($last_name_first) {
|
||||
return $this->last_name.', '.$this->first_name;
|
||||
return ($this->last_name.', '.$this->first_name);
|
||||
}
|
||||
|
||||
return $this->first_name.' '.$this->last_name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,18 @@ class AuditionCacheService
|
|||
});
|
||||
}
|
||||
|
||||
public function getPublishedAdvancementAuditions()
|
||||
{
|
||||
$cacheKey = 'publishedAdvancementAuditions';
|
||||
return Cache::remember(
|
||||
$cacheKey,
|
||||
now()->addHour(),
|
||||
function () {
|
||||
return Audition::with('flags')->orderBy('score_order')->get()->filter(fn ($audition) => $audition->hasFlag('advancement_published'));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function clearPublishedAuditionsCache(): void
|
||||
{
|
||||
Cache::forget('publishedAuditions');
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mx-auto max-w-sm mt-8">
|
||||
<div class="mx-auto max-w-3xl mt-8">
|
||||
|
||||
{{ $slot }}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<p class="text-xs font-medium text-gray-500">Click to open</p>
|
||||
</div>
|
||||
|
||||
<ul role="list" class="divide-y divide-gray-100" x-show="open">
|
||||
<ul role="list" class="divide-y divide-gray-100" x-show="open" x-cloak>
|
||||
{{ $slot }}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
@props(['student_name','school'])
|
||||
<li {{ $attributes->class(['flex gap-x-4 px-3 py-2 justify-between bg-gray-50 border-x border-b shadow']) }}>
|
||||
|
||||
<p class="text-sm font-semibold leading-6 text-gray-900">{{ htmlspecialchars_decode($student_name) }}</p>
|
||||
<p class="mt-1 truncate text-xs leading-5 text-gray-500">{{ $school }}</p>
|
||||
|
||||
</li>
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
@props(['seat','student_name','school'])
|
||||
@props(['seat', 'student_name','school'])
|
||||
<li {{ $attributes->class(['flex gap-x-4 px-3 py-2 justify-between bg-gray-50 border-x border-b shadow']) }}>
|
||||
|
||||
<div class="text-sm font-semibold">
|
||||
{{ $seat }}
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 text-right">
|
||||
<p class="text-sm font-semibold leading-6 text-gray-900">{{ $student_name }}</p>
|
||||
<p class="mt-1 truncate text-xs leading-5 text-gray-500">{{ $school }}</p>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<x-results.layout>
|
||||
|
||||
<nav class="h-full overflow-y-auto">
|
||||
<div class="w-full md:flex justify-between gap-8 @if(! auditionSetting('advanceTo') ) max-w-sm mx-auto @endif">
|
||||
<div class="h-full overflow-y-auto w-full">
|
||||
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('auditionAbbreviation') }} Seats</h3>
|
||||
@foreach($publishedAuditions as $audition)
|
||||
<x-results.table-audition-section :auditionName="$audition->name">
|
||||
@foreach($resultsSeatList[$audition->id] as $seat)
|
||||
|
|
@ -11,6 +12,23 @@
|
|||
@endforeach
|
||||
</x-results.table-audition-section>
|
||||
@endforeach
|
||||
</nav>
|
||||
</div>
|
||||
@if( auditionSetting('advanceTo') )
|
||||
<div class="h-full overflow-y-auto w-full">
|
||||
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('advanceTo') }} Qualifiers</h3>
|
||||
@foreach($publishedAdvancementAuditions as $audition)
|
||||
<x-results.table-audition-section :auditionName="$audition->name">
|
||||
@foreach($resultsAdvancementList[$audition->id] as $entry)
|
||||
<x-results.table-qualifier-row
|
||||
:student_name="$entry->student->full_name()"
|
||||
:school="$entry->student->school->name" />
|
||||
@endforeach
|
||||
</x-results.table-audition-section>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</x-results.layout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue