diff --git a/app/Http/Controllers/ResultsPage.php b/app/Http/Controllers/ResultsPage.php index 326d5f6..c00f5e5 100644 --- a/app/Http/Controllers/ResultsPage.php +++ b/app/Http/Controllers/ResultsPage.php @@ -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')); } } diff --git a/app/Models/Student.php b/app/Models/Student.php index 454cfb9..f93465b 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -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; } } diff --git a/app/Services/AuditionCacheService.php b/app/Services/AuditionCacheService.php index 12968cc..46e5b32 100644 --- a/app/Services/AuditionCacheService.php +++ b/app/Services/AuditionCacheService.php @@ -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'); diff --git a/resources/views/components/results/layout.blade.php b/resources/views/components/results/layout.blade.php index de256c0..2d2e67c 100644 --- a/resources/views/components/results/layout.blade.php +++ b/resources/views/components/results/layout.blade.php @@ -35,7 +35,7 @@ -
Click to open
{{ htmlspecialchars_decode($student_name) }}
+{{ $school }}
+ +{{ $student_name }}
{{ $school }}
diff --git a/resources/views/results/index.blade.php b/resources/views/results/index.blade.php index 3f252ca..f2383ce 100644 --- a/resources/views/results/index.blade.php +++ b/resources/views/results/index.blade.php @@ -1,16 +1,34 @@