Fix TODO modifying audition limits should refresh the acceptance limits cache
This commit is contained in:
parent
4201396d03
commit
43889d9587
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SeatingLimitChange
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||||
|
*/
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel('channel-name'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\SeatingLimitChange;
|
||||||
|
use App\Services\SeatingService;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class RefreshSeatingLimitCache
|
||||||
|
{
|
||||||
|
protected $seatingService;
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*/
|
||||||
|
public function __construct(SeatingService $seatingService)
|
||||||
|
{
|
||||||
|
$this->seatingService = $seatingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*/
|
||||||
|
public function handle(SeatingLimitChange $event): void
|
||||||
|
{
|
||||||
|
$this->seatingService->refreshLimits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Events\ScoringGuideChange;
|
||||||
|
use App\Models\SeatingLimit;
|
||||||
|
|
||||||
|
class SeatingLimitObserver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the SeatingLimit "created" event.
|
||||||
|
*/
|
||||||
|
public function created(SeatingLimit $seatingLimit): void
|
||||||
|
{
|
||||||
|
ScoringGuideChange::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the SeatingLimit "updated" event.
|
||||||
|
*/
|
||||||
|
public function updated(SeatingLimit $seatingLimit): void
|
||||||
|
{
|
||||||
|
ScoringGuideChange::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the SeatingLimit "deleted" event.
|
||||||
|
*/
|
||||||
|
public function deleted(SeatingLimit $seatingLimit): void
|
||||||
|
{
|
||||||
|
ScoringGuideChange::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the SeatingLimit "restored" event.
|
||||||
|
*/
|
||||||
|
public function restored(SeatingLimit $seatingLimit): void
|
||||||
|
{
|
||||||
|
ScoringGuideChange::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the SeatingLimit "force deleted" event.
|
||||||
|
*/
|
||||||
|
public function forceDeleted(SeatingLimit $seatingLimit): void
|
||||||
|
{
|
||||||
|
ScoringGuideChange::dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,10 +6,12 @@ use App\Events\AuditionChange;
|
||||||
use App\Events\EntryChange;
|
use App\Events\EntryChange;
|
||||||
use App\Events\ScoreSheetChange;
|
use App\Events\ScoreSheetChange;
|
||||||
use App\Events\ScoringGuideChange;
|
use App\Events\ScoringGuideChange;
|
||||||
|
use App\Events\SeatingLimitChange;
|
||||||
use App\Listeners\RefreshAuditionCache;
|
use App\Listeners\RefreshAuditionCache;
|
||||||
use App\Listeners\RefreshEntryCache;
|
use App\Listeners\RefreshEntryCache;
|
||||||
use App\Listeners\RefreshScoreSheetCache;
|
use App\Listeners\RefreshScoreSheetCache;
|
||||||
use App\Listeners\RefreshScoringGuideCache;
|
use App\Listeners\RefreshScoringGuideCache;
|
||||||
|
use App\Listeners\RefreshSeatingLimitCache;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\Room;
|
use App\Models\Room;
|
||||||
|
|
@ -17,6 +19,7 @@ use App\Models\RoomUser;
|
||||||
use App\Models\School;
|
use App\Models\School;
|
||||||
use App\Models\ScoreSheet;
|
use App\Models\ScoreSheet;
|
||||||
use App\Models\ScoringGuide;
|
use App\Models\ScoringGuide;
|
||||||
|
use App\Models\SeatingLimit;
|
||||||
use App\Models\Student;
|
use App\Models\Student;
|
||||||
use App\Models\SubscoreDefinition;
|
use App\Models\SubscoreDefinition;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
@ -27,6 +30,7 @@ use App\Observers\RoomUserObserver;
|
||||||
use App\Observers\SchoolObserver;
|
use App\Observers\SchoolObserver;
|
||||||
use App\Observers\ScoreSheetObserver;
|
use App\Observers\ScoreSheetObserver;
|
||||||
use App\Observers\ScoringGuideObserver;
|
use App\Observers\ScoringGuideObserver;
|
||||||
|
use App\Observers\SeatingLimitObserver;
|
||||||
use App\Observers\StudentObserver;
|
use App\Observers\StudentObserver;
|
||||||
use App\Observers\SubscoreDefinitionObserver;
|
use App\Observers\SubscoreDefinitionObserver;
|
||||||
use App\Observers\UserObserver;
|
use App\Observers\UserObserver;
|
||||||
|
|
@ -90,6 +94,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Student::observe(StudentObserver::class);
|
Student::observe(StudentObserver::class);
|
||||||
SubscoreDefinition::observe(SubscoreDefinitionObserver::class);
|
SubscoreDefinition::observe(SubscoreDefinitionObserver::class);
|
||||||
User::observe(UserObserver::class);
|
User::observe(UserObserver::class);
|
||||||
|
SeatingLimit::observe(SeatingLimitObserver::class);
|
||||||
|
|
||||||
Event::listen(
|
Event::listen(
|
||||||
AuditionChange::class,
|
AuditionChange::class,
|
||||||
|
|
@ -110,5 +115,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
ScoreSheetChange::class,
|
ScoreSheetChange::class,
|
||||||
RefreshScoreSheetCache::class
|
RefreshScoreSheetCache::class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Event::listen(
|
||||||
|
SeatingLimitChange::class,
|
||||||
|
RefreshSeatingLimitCache::class
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class SeatingService
|
||||||
|
|
||||||
public function getAcceptanceLimits()
|
public function getAcceptanceLimits()
|
||||||
{
|
{
|
||||||
// TODO modifying audition limits should refresh this cache
|
// TODO modifying audition limits should refresh the acceptance limits cache
|
||||||
return Cache::remember($this->limitsCacheKey, now()->addDay(), function () {
|
return Cache::remember($this->limitsCacheKey, now()->addDay(), function () {
|
||||||
$limits = SeatingLimit::with('ensemble')->get();
|
$limits = SeatingLimit::with('ensemble')->get();
|
||||||
// Sort limits by ensemble->rank
|
// Sort limits by ensemble->rank
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue