Remove RoomJudge service
This commit is contained in:
parent
51e59256ef
commit
973dcd7844
|
|
@ -13,13 +13,13 @@ use Illuminate\Queue\SerializesModels;
|
||||||
class AuditionChange
|
class AuditionChange
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
public bool $refreshCache;
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(bool $refreshCache = true)
|
||||||
{
|
{
|
||||||
//
|
$this->refreshCache = $refreshCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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 RoomJudgeChange
|
|
||||||
{
|
|
||||||
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'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -60,7 +60,7 @@ class AuditionController extends Controller
|
||||||
'minimum_grade' => $validData['minimum_grade'],
|
'minimum_grade' => $validData['minimum_grade'],
|
||||||
'maximum_grade' => $validData['maximum_grade'],
|
'maximum_grade' => $validData['maximum_grade'],
|
||||||
]);
|
]);
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/auditions');
|
return redirect('/admin/auditions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ class AuditionController extends Controller
|
||||||
'minimum_grade' => $validData['minimum_grade'],
|
'minimum_grade' => $validData['minimum_grade'],
|
||||||
'maximum_grade' => $validData['maximum_grade'],
|
'maximum_grade' => $validData['maximum_grade'],
|
||||||
]);
|
]);
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/auditions');
|
return redirect('/admin/auditions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ class AuditionController extends Controller
|
||||||
$audition = Audition::find($id);
|
$audition = Audition::find($id);
|
||||||
$audition->update(['score_order' => $index]);
|
$audition->update(['score_order' => $index]);
|
||||||
}
|
}
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return response()->json(['status' => 'success']);
|
return response()->json(['status' => 'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ class AuditionController extends Controller
|
||||||
'order_in_room' => $audition['room_order']
|
'order_in_room' => $audition['room_order']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return response()->json(['status' => 'success']);
|
return response()->json(['status' => 'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ class AuditionController extends Controller
|
||||||
|
|
||||||
return response()->json(['success' => true]);
|
return response()->json(['success' => true]);
|
||||||
}
|
}
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return response()->json(['success' => false], 404);
|
return response()->json(['success' => false], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ class AuditionController extends Controller
|
||||||
return redirect()->route('adminAuditionIndex')->with('error', 'Cannot delete an audition with entries.');
|
return redirect()->route('adminAuditionIndex')->with('error', 'Cannot delete an audition with entries.');
|
||||||
}
|
}
|
||||||
$audition->delete();
|
$audition->delete();
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/auditions');
|
return redirect('/admin/auditions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Events\AuditionChange;
|
||||||
use App\Events\RoomJudgeChange;
|
use App\Events\RoomJudgeChange;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
|
|
@ -21,7 +22,7 @@ class RoomController extends Controller
|
||||||
return view('admin.rooms.index', ['rooms' => $rooms]);
|
return view('admin.rooms.index', ['rooms' => $rooms]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function judgingAssignment()
|
public function judgingAssignment() // Show form for assigning judges
|
||||||
{
|
{
|
||||||
$usersWithoutRooms = User::doesntHave('rooms')->orderBy('last_name')->orderBy('first_name')->get();
|
$usersWithoutRooms = User::doesntHave('rooms')->orderBy('last_name')->orderBy('first_name')->get();
|
||||||
$usersWithRooms = User::has('rooms')->orderBy('last_name')->orderBy('first_name')->get();
|
$usersWithRooms = User::has('rooms')->orderBy('last_name')->orderBy('first_name')->get();
|
||||||
|
|
@ -48,7 +49,7 @@ class RoomController extends Controller
|
||||||
} else {
|
} else {
|
||||||
return redirect('/admin/rooms/judging_assignments')->with('error', 'Invalid request method.');
|
return redirect('/admin/rooms/judging_assignments')->with('error', 'Invalid request method.');
|
||||||
}
|
}
|
||||||
RoomJudgeChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/rooms/judging_assignments')->with('success',$message);
|
return redirect('/admin/rooms/judging_assignments')->with('success',$message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class ScoringGuideController extends Controller
|
||||||
'name' => request('name')
|
'name' => request('name')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
|
|
||||||
return redirect('/admin/scoring');
|
return redirect('/admin/scoring');
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ class ScoringGuideController extends Controller
|
||||||
$guide->update([
|
$guide->update([
|
||||||
'name' => request('name')
|
'name' => request('name')
|
||||||
]);
|
]);
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Scoring guide updated');
|
return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Scoring guide updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ class ScoringGuideController extends Controller
|
||||||
'for_seating' => $for_seating,
|
'for_seating' => $for_seating,
|
||||||
'for_advance' => $for_advance,
|
'for_advance' => $for_advance,
|
||||||
]);
|
]);
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Subscore added');
|
return redirect('/admin/scoring/guides/' . $guide->id . '/edit' )->with('success','Subscore added');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ class ScoringGuideController extends Controller
|
||||||
$subscore = SubscoreDefinition::find($id);
|
$subscore = SubscoreDefinition::find($id);
|
||||||
$subscore->update(['display_order' => $index]);
|
$subscore->update(['display_order' => $index]);
|
||||||
}
|
}
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return response()->json(['status'=>'success']);
|
return response()->json(['status'=>'success']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ class ScoringGuideController extends Controller
|
||||||
$subscore = SubscoreDefinition::find($id);
|
$subscore = SubscoreDefinition::find($id);
|
||||||
$subscore->update(['tiebreak_order' => $index]);
|
$subscore->update(['tiebreak_order' => $index]);
|
||||||
}
|
}
|
||||||
AuditionChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return response()->json(['status'=>'success']);
|
return response()->json(['status'=>'success']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Events\AuditionChange;
|
||||||
use App\Events\RoomJudgeChange;
|
use App\Events\RoomJudgeChange;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Mail\NewUserPassword;
|
use App\Mail\NewUserPassword;
|
||||||
|
|
@ -57,7 +58,7 @@ class UserController extends Controller
|
||||||
'judging_preference' => request('judging_preference'),
|
'judging_preference' => request('judging_preference'),
|
||||||
'school_id' => request('school_id')
|
'school_id' => request('school_id')
|
||||||
]);
|
]);
|
||||||
RoomJudgeChange::dispatch();
|
AuditionChange::dispatch(false);
|
||||||
return redirect('/admin/users');
|
return redirect('/admin/users');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Events\AuditionChange;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\School;
|
use App\Models\School;
|
||||||
|
|
@ -35,7 +36,7 @@ class EntryController extends Controller
|
||||||
'student_id' => request('student_id'),
|
'student_id' => request('student_id'),
|
||||||
'audition_id' => request('audition_id')
|
'audition_id' => request('audition_id')
|
||||||
]);
|
]);
|
||||||
|
AuditionChange::dispatch();
|
||||||
return redirect('/entries');
|
return redirect('/entries');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,6 +44,7 @@ class EntryController extends Controller
|
||||||
{
|
{
|
||||||
if ($request->user()->cannot('delete', $entry)) abort(403);
|
if ($request->user()->cannot('delete', $entry)) abort(403);
|
||||||
$entry->delete();
|
$entry->delete();
|
||||||
|
AuditionChange::dispatch();
|
||||||
return redirect('/entries')->with('success','The ' . $entry->audition->name . 'entry for ' . $entry->student->full_name(). 'has been deleted.');
|
return redirect('/entries')->with('success','The ' . $entry->audition->name . 'entry for ' . $entry->student->full_name(). 'has been deleted.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
class RefreshAuditionCache
|
class RefreshAuditionCache
|
||||||
{
|
{
|
||||||
protected $cacheService;
|
protected $auditionCacheService;
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*/
|
*/
|
||||||
public function __construct(AuditionCacheService $cacheService)
|
public function __construct(AuditionCacheService $cacheService)
|
||||||
{
|
{
|
||||||
$this->cacheService = $cacheService;
|
$this->auditionCacheService = $cacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,7 +23,11 @@ class RefreshAuditionCache
|
||||||
*/
|
*/
|
||||||
public function handle(AuditionChange $event): void
|
public function handle(AuditionChange $event): void
|
||||||
{
|
{
|
||||||
$this->cacheService->refreshCache();
|
if ($event->refreshCache) {
|
||||||
|
$this->auditionCacheService->refreshCache();
|
||||||
|
} else {
|
||||||
|
$this->auditionCacheService->clearCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Listeners;
|
|
||||||
|
|
||||||
use App\Events\RoomJudgeChange;
|
|
||||||
use App\Services\AuditionCacheService;
|
|
||||||
use App\Services\RoomAndJudgeCacheService;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
|
|
||||||
class RefreshRoomJudgeCache
|
|
||||||
{
|
|
||||||
protected $cacheService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the event listener.
|
|
||||||
*/
|
|
||||||
public function __construct(RoomAndJudgeCacheService $cacheService)
|
|
||||||
{
|
|
||||||
$this->cacheService = $cacheService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the event.
|
|
||||||
*/
|
|
||||||
public function handle(RoomJudgeChange $event): void
|
|
||||||
{
|
|
||||||
$this->cacheService->refreshCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -39,4 +39,9 @@ class AuditionCacheService
|
||||||
Cache::forget($this->cacheKey);
|
Cache::forget($this->cacheKey);
|
||||||
$this->getAuditions();
|
$this->getAuditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearCache()
|
||||||
|
{
|
||||||
|
Cache::forget($this->cacheKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services;
|
|
||||||
|
|
||||||
use App\Models\Audition;
|
|
||||||
use App\Models\Room;
|
|
||||||
use App\Models\ScoringGuide;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
|
|
||||||
class RoomAndJudgeCacheService
|
|
||||||
{
|
|
||||||
protected $cacheKey = 'roomJudge';
|
|
||||||
/**
|
|
||||||
* Create a new class instance.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAuditions()
|
|
||||||
{
|
|
||||||
return Cache::rememberForever($this->cacheKey, function () {
|
|
||||||
return Room::with(['judges'])->get();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function refreshCache()
|
|
||||||
{
|
|
||||||
Cache::forget($this->cacheKey);
|
|
||||||
$this->getAuditions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue