Add published auditions cache to AuditionCacheService

This commit is contained in:
Matt Young 2024-06-23 23:52:05 -05:00
parent 6469b063c1
commit d9041b329e
3 changed files with 21 additions and 3 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Tabulation;
use App\Http\Controllers\Controller;
use App\Models\Audition;
use App\Models\Seat;
use App\Services\AuditionCacheService;
use App\Services\DoublerService;
use App\Services\SeatingService;
use App\Services\TabulationService;
@ -20,11 +21,17 @@ class TabulationController extends Controller
protected $seatingService;
public function __construct(TabulationService $tabulationService, DoublerService $doublerService, SeatingService $seatingService)
protected $auditionCacheService;
public function __construct(TabulationService $tabulationService,
DoublerService $doublerService,
SeatingService $seatingService,
AuditionCacheService $auditionCacheService)
{
$this->tabulationService = $tabulationService;
$this->doublerService = $doublerService;
$this->seatingService = $seatingService;
$this->auditionCacheService = $auditionCacheService;
}
public function status()

View File

@ -58,4 +58,16 @@ class AuditionCacheService
}
Cache::forget($this->cacheKey);
}
public function publishedAuditions()
{
$cacheKey = 'publishedAuditions';
return Cache::remember(
$cacheKey,
now()->addHour(),
function () {
return Audition::orderBy('score_order')->get()->filter(fn ($audition) => $audition->hasFlag('seats_published'));
});
}
}

View File

@ -16,8 +16,7 @@
<x-layout.app>
<x-slot:page_title>Test Page</x-slot:page_title>
@php
$audition = Audition::find(2);
$audition->removeFlag('testFlag');
dump($auditionService->publishedAuditions());
@endphp