diff --git a/app/Services/AuditionCacheService.php b/app/Services/AuditionCacheService.php index f058888..5e9374d 100644 --- a/app/Services/AuditionCacheService.php +++ b/app/Services/AuditionCacheService.php @@ -4,7 +4,6 @@ namespace App\Services; use App\Models\Audition; use App\Models\ScoringGuide; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Session; @@ -12,6 +11,7 @@ use Illuminate\Support\Facades\Session; class AuditionCacheService { protected $cacheKey = 'auditions'; + /** * Create a new class instance. */ @@ -23,13 +23,15 @@ class AuditionCacheService /** * Return or fill cache of auditions including the audition, * scoringGuide.subscores, judges, judges_count, and entries_count - * @return Collection */ public function getAuditions(): \Illuminate\Database\Eloquent\Collection { - return Cache::remember($this->cacheKey, 3600, function () { - if (App::environment('local')) Session::flash('success','Audition Cache Updated'); - return Audition::with(['scoringGuide.subscores','judges']) + return Cache::remember($this->cacheKey, 3600, function () { + if (App::environment('local')) { + Session::flash('success', 'Audition Cache Updated'); + } + + return Audition::with(['scoringGuide.subscores', 'judges']) ->withCount('judges') ->withCount('entries') ->orderBy('score_order') @@ -40,10 +42,9 @@ class AuditionCacheService public function getAudition($id): Audition { - return $this->getAuditions()->firstWhere('id',$id); + return $this->getAuditions()->firstWhere('id', $id); } - public function refreshCache() { Cache::forget($this->cacheKey); @@ -52,7 +53,9 @@ class AuditionCacheService public function clearCache() { - if (App::environment('local')) Session::flash('success','Audition Cache Cleared'); + if (App::environment('local')) { + Session::flash('success', 'Audition Cache Cleared'); + } Cache::forget($this->cacheKey); } } diff --git a/app/Services/SeatingService.php b/app/Services/SeatingService.php index ead4970..2a6e224 100644 --- a/app/Services/SeatingService.php +++ b/app/Services/SeatingService.php @@ -4,11 +4,11 @@ namespace App\Services; use App\Models\SeatingLimit; use Illuminate\Support\Facades\Cache; -use function Pest\Laravel\get; class SeatingService { protected $limitsCacheKey = 'acceptanceLimits'; + /** * Create a new class instance. */ @@ -21,7 +21,13 @@ class SeatingService { // TODO modifying audition limits should refresh this cache return Cache::remember($this->limitsCacheKey, now()->addDay(), function () { - return SeatingLimit::all()->groupBy('audition_id'); + $limits = SeatingLimit::with('ensemble')->get(); + // Sort limits by ensemlbe->rank + $limits = $limits->sortBy(function ($limit) { + return $limit->ensemble->rank; + }); + + return $limits->groupBy('audition_id'); }); } @@ -30,7 +36,8 @@ class SeatingService return $this->getAcceptanceLimits()[$auditionId]; } - public function refershLimits() { + public function refershLimits() + { Cache::forget($this->limitsCacheKey); } } diff --git a/app/Services/TabulationService.php b/app/Services/TabulationService.php index 924e465..b856a48 100644 --- a/app/Services/TabulationService.php +++ b/app/Services/TabulationService.php @@ -132,7 +132,7 @@ class TabulationService foreach ($auditions as $audition) { $scored_entries_count = 0; foreach ($this->entryCacheService->getEntriesForAudition($audition->id) as $entry) { - if ($this->scoreService->entryScoreSheetCounts()[$entry->id] ?? $audition->judges_count == 0) { + if ($this->scoreService->entryScoreSheetCounts()[$entry->id] - $audition->judges_count == 0) { $scored_entries_count++; } } diff --git a/resources/views/tabulation/auditionSeating.blade.php b/resources/views/tabulation/auditionSeating.blade.php index ca91543..7cb75b9 100644 --- a/resources/views/tabulation/auditionSeating.blade.php +++ b/resources/views/tabulation/auditionSeating.blade.php @@ -13,11 +13,13 @@ Seating Form
- @foreach($entries as $entry) - @if(! $entry->scoring_complete) - Entry {{ $entry->id }} is unscored. - @endif - @endforeach + @if(! $complete) + Unable to seat. Not all entries are scored.
+ @endif + + @if(! $doublerComplete) + Unable to seat. Not all doublers are resolved.
+ @endif