Add advancement results to results page
This commit is contained in:
parent
4c7de27a54
commit
f067dfbe84
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Entry;
|
||||||
use App\Models\Seat;
|
use App\Models\Seat;
|
||||||
use App\Services\AuditionCacheService;
|
use App\Services\AuditionCacheService;
|
||||||
use App\Services\SeatingService;
|
use App\Services\SeatingService;
|
||||||
|
|
@ -28,6 +29,8 @@ class ResultsPage extends Controller
|
||||||
$publishedAuditions = $this->auditionCacheService->getPublishedAuditions();
|
$publishedAuditions = $this->auditionCacheService->getPublishedAuditions();
|
||||||
$resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) {
|
$resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) {
|
||||||
$seatList = [];
|
$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) {
|
foreach ($publishedAuditions as $audition) {
|
||||||
$seats = $this->seatingService->getSeatsForAudition($audition->id);
|
$seats = $this->seatingService->getSeatsForAudition($audition->id);
|
||||||
$ensembles = $this->seatingService->getEnsemblesForEvent($audition->event_id);
|
$ensembles = $this->seatingService->getEnsemblesForEvent($audition->event_id);
|
||||||
|
|
@ -48,6 +51,24 @@ class ResultsPage extends Controller
|
||||||
return $seatList;
|
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
|
public function full_name(bool $last_name_first = false): string
|
||||||
{
|
{
|
||||||
if ($last_name_first) {
|
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;
|
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
|
public function clearPublishedAuditionsCache(): void
|
||||||
{
|
{
|
||||||
Cache::forget('publishedAuditions');
|
Cache::forget('publishedAuditions');
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-auto max-w-sm mt-8">
|
<div class="mx-auto max-w-3xl mt-8">
|
||||||
|
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<p class="text-xs font-medium text-gray-500">Click to open</p>
|
<p class="text-xs font-medium text-gray-500">Click to open</p>
|
||||||
</div>
|
</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 }}
|
{{ $slot }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</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']) }}>
|
<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">
|
<div class="text-sm font-semibold">
|
||||||
{{ $seat }}
|
{{ $seat }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="min-w-0 text-right">
|
<div class="min-w-0 text-right">
|
||||||
<p class="text-sm font-semibold leading-6 text-gray-900">{{ $student_name }}</p>
|
<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>
|
<p class="mt-1 truncate text-xs leading-5 text-gray-500">{{ $school }}</p>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,34 @@
|
||||||
<x-results.layout>
|
<x-results.layout>
|
||||||
|
<div class="w-full md:flex justify-between gap-8 @if(! auditionSetting('advanceTo') ) max-w-sm mx-auto @endif">
|
||||||
<nav class="h-full overflow-y-auto">
|
<div class="h-full overflow-y-auto w-full">
|
||||||
@foreach($publishedAuditions as $audition)
|
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('auditionAbbreviation') }} Seats</h3>
|
||||||
<x-results.table-audition-section :auditionName="$audition->name">
|
@foreach($publishedAuditions as $audition)
|
||||||
@foreach($resultsSeatList[$audition->id] as $seat)
|
<x-results.table-audition-section :auditionName="$audition->name">
|
||||||
<x-results.table-seat-row
|
@foreach($resultsSeatList[$audition->id] as $seat)
|
||||||
:seat="$seat['seat']"
|
<x-results.table-seat-row
|
||||||
:student_name="$seat['student']->full_name()"
|
:seat="$seat['seat']"
|
||||||
:school="$seat['student']->school->name" />
|
:student_name="$seat['student']->full_name()"
|
||||||
|
:school="$seat['student']->school->name" />
|
||||||
|
@endforeach
|
||||||
|
</x-results.table-audition-section>
|
||||||
|
@endforeach
|
||||||
|
</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
|
@endforeach
|
||||||
</x-results.table-audition-section>
|
</div>
|
||||||
@endforeach
|
@endif
|
||||||
</nav>
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</x-results.layout>
|
</x-results.layout>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue