Rewrite tabulation #14
|
|
@ -1,36 +0,0 @@
|
|||
<?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 AuditionChange
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
public bool $refreshCache;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(bool $refreshCache = false)
|
||||
{
|
||||
$this->refreshCache = $refreshCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('channel-name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?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 EntryChange
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
public int $auditionId;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct($auditionId = null)
|
||||
{
|
||||
$this->auditionId = $auditionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('channel-name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?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 ScoreSheetChange
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
public int $entryId;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct($entryId = null)
|
||||
{
|
||||
$this->entryId = $entryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('channel-name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?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 ScoringGuideChange
|
||||
{
|
||||
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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\AuditionChange;
|
||||
use App\Services\AuditionService;
|
||||
|
||||
class RefreshAuditionCache
|
||||
{
|
||||
protected $auditionService;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(AuditionService $cacheService)
|
||||
{
|
||||
$this->auditionService = $cacheService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(AuditionChange $event): void
|
||||
{
|
||||
if ($event->refreshCache) {
|
||||
$this->auditionService->refreshCache();
|
||||
} else {
|
||||
$this->auditionService->clearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\AuditionChange;
|
||||
use App\Events\EntryChange;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\EntryService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class RefreshEntryCache
|
||||
{
|
||||
protected $entryService;
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(EntryService $cacheService)
|
||||
{
|
||||
$this->entryService = $cacheService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(EntryChange $event): void
|
||||
{
|
||||
if ($event->auditionId) {
|
||||
$this->entryService->clearEntryCacheForAudition($event->auditionId);
|
||||
} else {
|
||||
$this->entryService->clearEntryCaches();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\ScoreSheetChange;
|
||||
use App\Services\ScoreService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class RefreshScoreSheetCache
|
||||
{
|
||||
protected $scoreService;
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(ScoreService $scoreService)
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\ScoringGuideChange;
|
||||
use App\Services\ScoreService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class RefreshScoringGuideCache
|
||||
{
|
||||
protected $scoreService;
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(ScoreService $scoreService)
|
||||
{
|
||||
$this->scoreService = $scoreService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(ScoringGuideChange $event): void
|
||||
{
|
||||
$this->scoreService->clearScoringGuideCache();
|
||||
$this->scoreService->clearAllCachedTotalScores();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue