From 55b6081fc6aa25fab3093ea97ee0387fb34953e7 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 20 Jun 2024 09:52:41 -0500 Subject: [PATCH] Acceptance limits show on seating page --- app/Providers/AppServiceProvider.php | 9 +++-- app/Services/DoublerService.php | 7 ++-- app/Services/SeatingService.php | 36 +++++++++++++++++++ .../views/components/doubler-block.blade.php | 6 +++- resources/views/test.blade.php | 3 +- 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 app/Services/SeatingService.php diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 98a1bfb..a74ab04 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -32,6 +32,7 @@ use App\Services\AuditionCacheService; use App\Services\DoublerService; use App\Services\EntryCacheService; use App\Services\ScoreService; +use App\Services\SeatingService; use App\Services\TabulationService; use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; @@ -47,6 +48,10 @@ class AppServiceProvider extends ServiceProvider return new AuditionCacheService(); }); + $this->app->singleton(SeatingService::class, function () { + return new SeatingService(); + }); + $this->app->singleton(EntryCacheService::class, function($app) { return new EntryCacheService($app->make(AuditionCacheService::class)); }); @@ -62,10 +67,8 @@ class AppServiceProvider extends ServiceProvider $app->make(EntryCacheService::class)); }); - - $this->app->singleton(DoublerService::class, function($app) { - return new DoublerService($app->make(AuditionCacheService::class),$app->make(TabulationService::class)); + return new DoublerService($app->make(AuditionCacheService::class),$app->make(TabulationService::class),$app->make(SeatingService::class)); }); } diff --git a/app/Services/DoublerService.php b/app/Services/DoublerService.php index 5406419..382ef24 100644 --- a/app/Services/DoublerService.php +++ b/app/Services/DoublerService.php @@ -11,13 +11,15 @@ class DoublerService protected $doublersCacheKey = 'doublers'; protected $auditionCacheService; protected $tabulationService; + protected $seatingService; /** * Create a new class instance. */ - public function __construct(AuditionCacheService $auditionCacheService, TabulationService $tabulationService) + public function __construct(AuditionCacheService $auditionCacheService, TabulationService $tabulationService, SeatingService $seatingService) { $this->auditionCacheService = $auditionCacheService; $this->tabulationService = $tabulationService; + $this->seatingService = $seatingService; } /** @@ -60,7 +62,8 @@ class DoublerService 'auditionID' => $entry->audition_id, 'auditionName' => $this->auditionCacheService->getAudition($entry->audition_id)->name, 'rank' => $this->tabulationService->entryRank($entry), - 'unscored' => $this->tabulationService->remainingEntriesForAudition($entry->audition_id) + 'unscored' => $this->tabulationService->remainingEntriesForAudition($entry->audition_id), + 'limits' => $this->seatingService->getLimitForAudition($entry->audition_id), ]; $entry->audition = $this->auditionCacheService->getAudition($entry->audition_id); } diff --git a/app/Services/SeatingService.php b/app/Services/SeatingService.php new file mode 100644 index 0000000..ead4970 --- /dev/null +++ b/app/Services/SeatingService.php @@ -0,0 +1,36 @@ +limitsCacheKey, now()->addDay(), function () { + return SeatingLimit::all()->groupBy('audition_id'); + }); + } + + public function getLimitForAudition($auditionId) + { + return $this->getAcceptanceLimits()[$auditionId]; + } + + public function refershLimits() { + Cache::forget($this->limitsCacheKey); + } +} diff --git a/resources/views/components/doubler-block.blade.php b/resources/views/components/doubler-block.blade.php index ba301df..46260ba 100644 --- a/resources/views/components/doubler-block.blade.php +++ b/resources/views/components/doubler-block.blade.php @@ -21,7 +21,11 @@

{{ $info['unscored'] }} Unscored

- Acceptance Limits +
diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php index ff1a39b..8107905 100644 --- a/resources/views/test.blade.php +++ b/resources/views/test.blade.php @@ -12,10 +12,11 @@ @inject('scoreservice','App\Services\ScoreService'); @inject('auditionService','App\Services\AuditionCacheService'); @inject('entryService','App\Services\EntryCacheService') +@inject('seatingService','App\Services\SeatingService') Test Page @php - dump($scoreservice->getScoringGuide(58)->subscores_count); + dump($seatingService->getLimitForAudition(47)); @endphp