diff --git a/app/Events/AuditionChange.php b/app/Events/AuditionChange.php deleted file mode 100644 index b8aa81a..0000000 --- a/app/Events/AuditionChange.php +++ /dev/null @@ -1,36 +0,0 @@ -refreshCache = $refreshCache; - } - - /** - * Get the channels the event should broadcast on. - * - * @return array - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Events/EntryChange.php b/app/Events/EntryChange.php deleted file mode 100644 index ae1890c..0000000 --- a/app/Events/EntryChange.php +++ /dev/null @@ -1,36 +0,0 @@ -auditionId = $auditionId; - } - - /** - * Get the channels the event should broadcast on. - * - * @return array - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Events/ScoreSheetChange.php b/app/Events/ScoreSheetChange.php deleted file mode 100644 index 7178c49..0000000 --- a/app/Events/ScoreSheetChange.php +++ /dev/null @@ -1,36 +0,0 @@ -entryId = $entryId; - } - - /** - * Get the channels the event should broadcast on. - * - * @return array - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Events/ScoringGuideChange.php b/app/Events/ScoringGuideChange.php deleted file mode 100644 index b265ad9..0000000 --- a/app/Events/ScoringGuideChange.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Events/SeatingLimitChange.php b/app/Events/SeatingLimitChange.php deleted file mode 100644 index 5217dfe..0000000 --- a/app/Events/SeatingLimitChange.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ - public function broadcastOn(): array - { - return [ - new PrivateChannel('channel-name'), - ]; - } -} diff --git a/app/Http/Controllers/Tabulation/TabulationController.php b/app/Http/Controllers/Tabulation/TabulationController.php index 78b5e7f..d11c3b2 100644 --- a/app/Http/Controllers/Tabulation/TabulationController.php +++ b/app/Http/Controllers/Tabulation/TabulationController.php @@ -37,6 +37,7 @@ class TabulationController extends Controller public function status() { + // Needs to provide a collection of auditions $auditions = $this->tabulationService->getAuditionsWithStatus('seating'); return view('tabulation.status', compact('auditions')); diff --git a/app/Listeners/RefreshAuditionCache.php b/app/Listeners/RefreshAuditionCache.php deleted file mode 100644 index 0728bad..0000000 --- a/app/Listeners/RefreshAuditionCache.php +++ /dev/null @@ -1,31 +0,0 @@ -auditionService = $cacheService; - } - - /** - * Handle the event. - */ - public function handle(AuditionChange $event): void - { - if ($event->refreshCache) { - $this->auditionService->refreshCache(); - } else { - $this->auditionService->clearCache(); - } - } -} diff --git a/app/Listeners/RefreshEntryCache.php b/app/Listeners/RefreshEntryCache.php deleted file mode 100644 index cac64e6..0000000 --- a/app/Listeners/RefreshEntryCache.php +++ /dev/null @@ -1,34 +0,0 @@ -entryService = $cacheService; - } - - /** - * Handle the event. - */ - public function handle(EntryChange $event): void - { - if ($event->auditionId) { - $this->entryService->clearEntryCacheForAudition($event->auditionId); - } else { - $this->entryService->clearEntryCaches(); - } - } -} diff --git a/app/Listeners/RefreshScoreSheetCache.php b/app/Listeners/RefreshScoreSheetCache.php deleted file mode 100644 index 1604550..0000000 --- a/app/Listeners/RefreshScoreSheetCache.php +++ /dev/null @@ -1,35 +0,0 @@ -scoreService = $scoreService; - } - - /** - * Handle the event. - */ - public function handle(ScoreSheetChange $event): void - { - $this->scoreService->clearScoreSheetCountCache(); - if ($event->entryId) { - $this->scoreService->clearEntryTotalScoresCache($event->entryId); - } - // If we are in local environment, send a success flash message - if (config('app.env') === 'local') { - session()->flash('success','Cleared cache for entry ID ' . $event->entryId); - } - } -} diff --git a/app/Listeners/RefreshScoringGuideCache.php b/app/Listeners/RefreshScoringGuideCache.php deleted file mode 100644 index 3a38cc4..0000000 --- a/app/Listeners/RefreshScoringGuideCache.php +++ /dev/null @@ -1,29 +0,0 @@ -scoreService = $scoreService; - } - - /** - * Handle the event. - */ - public function handle(ScoringGuideChange $event): void - { - $this->scoreService->clearScoringGuideCache(); - $this->scoreService->clearAllCachedTotalScores(); - } -} diff --git a/app/Listeners/RefreshSeatingLimitCache.php b/app/Listeners/RefreshSeatingLimitCache.php deleted file mode 100644 index d309d15..0000000 --- a/app/Listeners/RefreshSeatingLimitCache.php +++ /dev/null @@ -1,28 +0,0 @@ -seatingService = $seatingService; - } - - /** - * Handle the event. - */ - public function handle(SeatingLimitChange $event): void - { - $this->seatingService->refreshLimits(); - } -} diff --git a/app/Observers/AuditionObserver.php b/app/Observers/AuditionObserver.php index 27d139f..aa2bc4c 100644 --- a/app/Observers/AuditionObserver.php +++ b/app/Observers/AuditionObserver.php @@ -13,8 +13,7 @@ class AuditionObserver */ public function created(Audition $audition): void { - AuditionChange::dispatch(); - EntryChange::dispatch($audition->id); + // } /** @@ -22,8 +21,7 @@ class AuditionObserver */ public function updated(Audition $audition): void { - AuditionChange::dispatch(); - EntryChange::dispatch($audition->id); + // } /** @@ -31,8 +29,7 @@ class AuditionObserver */ public function deleted(Audition $audition): void { - AuditionChange::dispatch(); - EntryChange::dispatch($audition->id); + // } /** @@ -40,8 +37,7 @@ class AuditionObserver */ public function restored(Audition $audition): void { - AuditionChange::dispatch(); - EntryChange::dispatch($audition->id); + // } /** @@ -49,7 +45,6 @@ class AuditionObserver */ public function forceDeleted(Audition $audition): void { - AuditionChange::dispatch(); - EntryChange::dispatch($audition->id); + // } } diff --git a/app/Observers/RoomObserver.php b/app/Observers/RoomObserver.php index 984b373..ce2c790 100644 --- a/app/Observers/RoomObserver.php +++ b/app/Observers/RoomObserver.php @@ -20,7 +20,7 @@ class RoomObserver */ public function updated(Room $room): void { - AuditionChange::dispatch(); + // } /** @@ -28,7 +28,7 @@ class RoomObserver */ public function deleted(Room $room): void { - AuditionChange::dispatch(); + // } /** @@ -36,7 +36,7 @@ class RoomObserver */ public function restored(Room $room): void { - AuditionChange::dispatch(); + // } /** @@ -44,6 +44,6 @@ class RoomObserver */ public function forceDeleted(Room $room): void { - AuditionChange::dispatch(); + // } } diff --git a/app/Observers/RoomUserObserver.php b/app/Observers/RoomUserObserver.php index f089319..024f3ba 100644 --- a/app/Observers/RoomUserObserver.php +++ b/app/Observers/RoomUserObserver.php @@ -12,7 +12,7 @@ class RoomUserObserver */ public function created(RoomUser $roomUser): void { - AuditionChange::dispatch(); + // } /** @@ -20,7 +20,7 @@ class RoomUserObserver */ public function updated(RoomUser $roomUser): void { - AuditionChange::dispatch(); + // } /** @@ -28,7 +28,7 @@ class RoomUserObserver */ public function deleted(RoomUser $roomUser): void { - AuditionChange::dispatch(); + // } /** @@ -36,7 +36,7 @@ class RoomUserObserver */ public function restored(RoomUser $roomUser): void { - AuditionChange::dispatch(); + // } /** @@ -44,6 +44,6 @@ class RoomUserObserver */ public function forceDeleted(RoomUser $roomUser): void { - AuditionChange::dispatch(); + // } } diff --git a/app/Observers/ScoreSheetObserver.php b/app/Observers/ScoreSheetObserver.php index 533763e..ceb8711 100644 --- a/app/Observers/ScoreSheetObserver.php +++ b/app/Observers/ScoreSheetObserver.php @@ -12,7 +12,7 @@ class ScoreSheetObserver */ public function created(ScoreSheet $scoreSheet): void { - ScoreSheetChange::dispatch($scoreSheet->entry_id); + // } /** @@ -20,7 +20,7 @@ class ScoreSheetObserver */ public function updated(ScoreSheet $scoreSheet): void { - ScoreSheetChange::dispatch($scoreSheet->entry_id); + // } /** @@ -28,7 +28,7 @@ class ScoreSheetObserver */ public function deleted(ScoreSheet $scoreSheet): void { - ScoreSheetChange::dispatch($scoreSheet->entry_id); + // } /** @@ -36,7 +36,7 @@ class ScoreSheetObserver */ public function restored(ScoreSheet $scoreSheet): void { - ScoreSheetChange::dispatch($scoreSheet->entry_id); + // } /** @@ -44,6 +44,6 @@ class ScoreSheetObserver */ public function forceDeleted(ScoreSheet $scoreSheet): void { - ScoreSheetChange::dispatch($scoreSheet->entry_id); + // } } diff --git a/app/Observers/ScoringGuideObserver.php b/app/Observers/ScoringGuideObserver.php index 00a1dc7..bf35243 100644 --- a/app/Observers/ScoringGuideObserver.php +++ b/app/Observers/ScoringGuideObserver.php @@ -13,7 +13,7 @@ class ScoringGuideObserver */ public function created(ScoringGuide $scoringGuide): void { - ScoringGuideChange::dispatch(); + // } /** @@ -21,8 +21,7 @@ class ScoringGuideObserver */ public function updated(ScoringGuide $scoringGuide): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -30,8 +29,7 @@ class ScoringGuideObserver */ public function deleted(ScoringGuide $scoringGuide): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -39,8 +37,7 @@ class ScoringGuideObserver */ public function restored(ScoringGuide $scoringGuide): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -48,7 +45,6 @@ class ScoringGuideObserver */ public function forceDeleted(ScoringGuide $scoringGuide): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } } diff --git a/app/Observers/SeatingLimitObserver.php b/app/Observers/SeatingLimitObserver.php index 5b36ca7..4f4602f 100644 --- a/app/Observers/SeatingLimitObserver.php +++ b/app/Observers/SeatingLimitObserver.php @@ -12,7 +12,7 @@ class SeatingLimitObserver */ public function created(SeatingLimit $seatingLimit): void { - ScoringGuideChange::dispatch(); + // } /** @@ -20,7 +20,7 @@ class SeatingLimitObserver */ public function updated(SeatingLimit $seatingLimit): void { - ScoringGuideChange::dispatch(); + // } /** @@ -28,7 +28,7 @@ class SeatingLimitObserver */ public function deleted(SeatingLimit $seatingLimit): void { - ScoringGuideChange::dispatch(); + // } /** @@ -36,7 +36,7 @@ class SeatingLimitObserver */ public function restored(SeatingLimit $seatingLimit): void { - ScoringGuideChange::dispatch(); + // } /** @@ -44,6 +44,6 @@ class SeatingLimitObserver */ public function forceDeleted(SeatingLimit $seatingLimit): void { - ScoringGuideChange::dispatch(); + // } } diff --git a/app/Observers/SubscoreDefinitionObserver.php b/app/Observers/SubscoreDefinitionObserver.php index ae54dec..afbeccb 100644 --- a/app/Observers/SubscoreDefinitionObserver.php +++ b/app/Observers/SubscoreDefinitionObserver.php @@ -13,8 +13,7 @@ class SubscoreDefinitionObserver */ public function created(SubscoreDefinition $subscoreDefinition): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -22,8 +21,7 @@ class SubscoreDefinitionObserver */ public function updated(SubscoreDefinition $subscoreDefinition): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -31,8 +29,7 @@ class SubscoreDefinitionObserver */ public function deleted(SubscoreDefinition $subscoreDefinition): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -40,8 +37,7 @@ class SubscoreDefinitionObserver */ public function restored(SubscoreDefinition $subscoreDefinition): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } /** @@ -49,7 +45,6 @@ class SubscoreDefinitionObserver */ public function forceDeleted(SubscoreDefinition $subscoreDefinition): void { - AuditionChange::dispatch(); - ScoringGuideChange::dispatch(); + // } } diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index e1dc7d3..81c623f 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -20,7 +20,7 @@ class UserObserver */ public function updated(User $user): void { - AuditionChange::dispatch(); + // } /** @@ -28,7 +28,7 @@ class UserObserver */ public function deleted(User $user): void { - AuditionChange::dispatch(); + // } /** @@ -44,6 +44,6 @@ class UserObserver */ public function forceDeleted(User $user): void { - AuditionChange::dispatch(); + // } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 3107614..b804a12 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -102,29 +102,6 @@ class AppServiceProvider extends ServiceProvider User::observe(UserObserver::class); SeatingLimit::observe(SeatingLimitObserver::class); - Event::listen( - AuditionChange::class, - RefreshAuditionCache::class - ); - - Event::listen( - EntryChange::class, - RefreshEntryCache::class - ); - - Event::listen( - ScoringGuideChange::class, - RefreshScoringGuideCache::class - ); - - Event::listen( - ScoreSheetChange::class, - RefreshScoreSheetCache::class - ); - - Event::listen( - SeatingLimitChange::class, - RefreshSeatingLimitCache::class - ); + } } diff --git a/app/Services/AuditionService.php b/app/Services/AuditionService.php index 6e2d9a9..a9dc674 100644 --- a/app/Services/AuditionService.php +++ b/app/Services/AuditionService.php @@ -5,9 +5,7 @@ namespace App\Services; use App\Models\Audition; use App\Models\ScoringGuide; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Session; class AuditionService { @@ -28,19 +26,20 @@ class AuditionService public function getAuditions($mode = 'seating'): \Illuminate\Database\Eloquent\Collection { $auditions = 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') - ->withCount(['entries as seating_entries_count' => function (Builder $query) { - $query->where('for_seating', true); - }]) - ->withCount(['entries as advancement_entries_count' => function (Builder $query) { - $query->where('for_advancement', true); - }]) + ->withCount([ + 'entries as seating_entries_count' => function (Builder $query) { + $query->where('for_seating', true); + }, + ]) + ->withCount([ + 'entries as advancement_entries_count' => function (Builder $query) { + $query->where('for_advancement', true); + }, + ]) ->orderBy('score_order') ->get() ->keyBy('id'); @@ -80,18 +79,21 @@ class AuditionService $cacheKey, now()->addHour(), function () { - return Audition::with('flags')->orderBy('score_order')->get()->filter(fn ($audition) => $audition->hasFlag('seats_published')); + return Audition::with('flags')->orderBy('score_order')->get()->filter(fn ($audition + ) => $audition->hasFlag('seats_published')); }); } public function getPublishedAdvancementAuditions() { $cacheKey = 'publishedAdvancementAuditions'; + return Cache::remember( $cacheKey, now()->addHour(), function () { - return Audition::with('flags')->orderBy('score_order')->get()->filter(fn ($audition) => $audition->hasFlag('advancement_published')); + return Audition::with('flags')->orderBy('score_order')->get()->filter(fn ($audition + ) => $audition->hasFlag('advancement_published')); }); }