Add published auditions cache to AuditionCacheService
This commit is contained in:
parent
6469b063c1
commit
d9041b329e
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Tabulation;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use App\Models\Seat;
|
use App\Models\Seat;
|
||||||
|
use App\Services\AuditionCacheService;
|
||||||
use App\Services\DoublerService;
|
use App\Services\DoublerService;
|
||||||
use App\Services\SeatingService;
|
use App\Services\SeatingService;
|
||||||
use App\Services\TabulationService;
|
use App\Services\TabulationService;
|
||||||
|
|
@ -20,11 +21,17 @@ class TabulationController extends Controller
|
||||||
|
|
||||||
protected $seatingService;
|
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->tabulationService = $tabulationService;
|
||||||
$this->doublerService = $doublerService;
|
$this->doublerService = $doublerService;
|
||||||
$this->seatingService = $seatingService;
|
$this->seatingService = $seatingService;
|
||||||
|
$this->auditionCacheService = $auditionCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function status()
|
public function status()
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,16 @@ class AuditionCacheService
|
||||||
}
|
}
|
||||||
Cache::forget($this->cacheKey);
|
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'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@
|
||||||
<x-layout.app>
|
<x-layout.app>
|
||||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||||
@php
|
@php
|
||||||
$audition = Audition::find(2);
|
dump($auditionService->publishedAuditions());
|
||||||
$audition->removeFlag('testFlag');
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue