Rename services
This commit is contained in:
parent
3f88c3dbfa
commit
80f2242e52
|
|
@ -4,21 +4,21 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Models\Entry;
|
||||
use App\Models\Seat;
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\SeatingService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ResultsPage extends Controller
|
||||
{
|
||||
protected $auditionCacheService;
|
||||
protected $auditionService;
|
||||
|
||||
protected $seatingService;
|
||||
|
||||
public function __construct(AuditionCacheService $auditionCacheService, SeatingService $seatingService)
|
||||
public function __construct(AuditionService $auditionService, SeatingService $seatingService)
|
||||
{
|
||||
$this->auditionCacheService = $auditionCacheService;
|
||||
$this->seatingService = $seatingService;
|
||||
$this->auditionService = $auditionService;
|
||||
$this->seatingService = $seatingService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,7 +26,7 @@ class ResultsPage extends Controller
|
|||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$publishedAuditions = $this->auditionCacheService->getPublishedAuditions();
|
||||
$publishedAuditions = $this->auditionService->getPublishedAuditions();
|
||||
$resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) {
|
||||
$seatList = [];
|
||||
// Load the $seatList in the form of $seatlist[audition_id] is an array of seats for that audition
|
||||
|
|
@ -51,7 +51,7 @@ class ResultsPage extends Controller
|
|||
return $seatList;
|
||||
});
|
||||
|
||||
$publishedAdvancementAuditions = $this->auditionCacheService->getPublishedAdvancementAuditions();
|
||||
$publishedAdvancementAuditions = $this->auditionService->getPublishedAdvancementAuditions();
|
||||
$resultsAdvancementList = Cache::rememberForever('resultsAdvancementList', function () use ($publishedAdvancementAuditions) {
|
||||
$qualifierList = [];
|
||||
foreach ($publishedAdvancementAuditions as $audition) {
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Entry;
|
||||
use App\Models\EntryFlag;
|
||||
use App\Services\DoublerService;
|
||||
use App\Services\EntryCacheService;
|
||||
use App\Services\EntryService;
|
||||
|
||||
class DoublerDecisionController extends Controller
|
||||
{
|
||||
protected $doublerService;
|
||||
protected $entryService;
|
||||
|
||||
public function __construct(DoublerService $doublerService, EntryCacheService $entryService)
|
||||
public function __construct(DoublerService $doublerService, EntryService $entryService)
|
||||
{
|
||||
$this->doublerService = $doublerService;
|
||||
$this->entryService = $entryService;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace App\Http\Controllers\Tabulation;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Audition;
|
||||
use App\Models\Seat;
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\DoublerService;
|
||||
use App\Services\SeatingService;
|
||||
use App\Services\TabulationService;
|
||||
|
|
@ -22,17 +22,17 @@ class TabulationController extends Controller
|
|||
|
||||
protected $seatingService;
|
||||
|
||||
protected $auditionCacheService;
|
||||
protected $auditionService;
|
||||
|
||||
public function __construct(TabulationService $tabulationService,
|
||||
DoublerService $doublerService,
|
||||
SeatingService $seatingService,
|
||||
AuditionCacheService $auditionCacheService)
|
||||
AuditionService $auditionService)
|
||||
{
|
||||
$this->tabulationService = $tabulationService;
|
||||
$this->doublerService = $doublerService;
|
||||
$this->seatingService = $seatingService;
|
||||
$this->auditionCacheService = $auditionCacheService;
|
||||
$this->auditionService = $auditionService;
|
||||
}
|
||||
|
||||
public function status()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\TabulationService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
|
@ -12,7 +12,7 @@ class TestController extends Controller
|
|||
protected $scoringGuideCacheService;
|
||||
protected $tabulationService;
|
||||
|
||||
public function __construct(AuditionCacheService $scoringGuideCacheService, TabulationService $tabulationService)
|
||||
public function __construct(AuditionService $scoringGuideCacheService, TabulationService $tabulationService)
|
||||
{
|
||||
$this->scoringGuideCacheService = $scoringGuideCacheService;
|
||||
$this->tabulationService = $tabulationService;
|
||||
|
|
|
|||
|
|
@ -3,19 +3,18 @@
|
|||
namespace App\Listeners;
|
||||
|
||||
use App\Events\AuditionChange;
|
||||
use App\Services\AuditionCacheService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Services\AuditionService;
|
||||
|
||||
class RefreshAuditionCache
|
||||
{
|
||||
protected $auditionCacheService;
|
||||
protected $auditionService;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(AuditionCacheService $cacheService)
|
||||
public function __construct(AuditionService $cacheService)
|
||||
{
|
||||
$this->auditionCacheService = $cacheService;
|
||||
$this->auditionService = $cacheService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -24,9 +23,9 @@ class RefreshAuditionCache
|
|||
public function handle(AuditionChange $event): void
|
||||
{
|
||||
if ($event->refreshCache) {
|
||||
$this->auditionCacheService->refreshCache();
|
||||
$this->auditionService->refreshCache();
|
||||
} else {
|
||||
$this->auditionCacheService->clearCache();
|
||||
$this->auditionService->clearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@ namespace App\Listeners;
|
|||
|
||||
use App\Events\AuditionChange;
|
||||
use App\Events\EntryChange;
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\EntryCacheService;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\EntryService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class RefreshEntryCache
|
||||
{
|
||||
protected $entryCacheService;
|
||||
protected $entryService;
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct(EntryCacheService $cacheService)
|
||||
public function __construct(EntryService $cacheService)
|
||||
{
|
||||
$this->entryCacheService = $cacheService;
|
||||
$this->entryService = $cacheService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,9 +26,9 @@ class RefreshEntryCache
|
|||
public function handle(EntryChange $event): void
|
||||
{
|
||||
if ($event->auditionId) {
|
||||
$this->entryCacheService->clearEntryCacheForAudition($event->auditionId);
|
||||
$this->entryService->clearEntryCacheForAudition($event->auditionId);
|
||||
} else {
|
||||
$this->entryCacheService->clearEntryCaches();
|
||||
$this->entryService->clearEntryCaches();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ use App\Observers\SeatingLimitObserver;
|
|||
use App\Observers\StudentObserver;
|
||||
use App\Observers\SubscoreDefinitionObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use App\Services\AuditionCacheService;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\DoublerService;
|
||||
use App\Services\EntryCacheService;
|
||||
use App\Services\EntryService;
|
||||
use App\Services\ScoreService;
|
||||
use App\Services\SeatingService;
|
||||
use App\Services\TabulationService;
|
||||
|
|
@ -50,31 +50,31 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(AuditionCacheService::class, function () {
|
||||
return new AuditionCacheService();
|
||||
$this->app->singleton(AuditionService::class, function () {
|
||||
return new AuditionService();
|
||||
});
|
||||
|
||||
$this->app->singleton(SeatingService::class, function ($app) {
|
||||
return new SeatingService($app->make(TabulationService::class));
|
||||
});
|
||||
|
||||
$this->app->singleton(EntryCacheService::class, function ($app) {
|
||||
return new EntryCacheService($app->make(AuditionCacheService::class));
|
||||
$this->app->singleton(EntryService::class, function ($app) {
|
||||
return new EntryService($app->make(AuditionService::class));
|
||||
});
|
||||
|
||||
$this->app->singleton(ScoreService::class, function ($app) {
|
||||
return new ScoreService($app->make(AuditionCacheService::class), $app->make(EntryCacheService::class));
|
||||
return new ScoreService($app->make(AuditionService::class), $app->make(EntryService::class));
|
||||
});
|
||||
|
||||
$this->app->singleton(TabulationService::class, function ($app) {
|
||||
return new TabulationService(
|
||||
$app->make(AuditionCacheService::class),
|
||||
$app->make(AuditionService::class),
|
||||
$app->make(ScoreService::class),
|
||||
$app->make(EntryCacheService::class));
|
||||
$app->make(EntryService::class));
|
||||
});
|
||||
|
||||
$this->app->singleton(DoublerService::class, function ($app) {
|
||||
return new DoublerService($app->make(AuditionCacheService::class), $app->make(TabulationService::class), $app->make(SeatingService::class));
|
||||
return new DoublerService($app->make(AuditionService::class), $app->make(TabulationService::class), $app->make(SeatingService::class));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\Support\Facades\App;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class AuditionCacheService
|
||||
class AuditionService
|
||||
{
|
||||
protected $cacheKey = 'auditions';
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ class DoublerService
|
|||
{
|
||||
protected $doublersCacheKey = 'doublers';
|
||||
|
||||
protected $auditionCacheService;
|
||||
protected $auditionService;
|
||||
|
||||
protected $tabulationService;
|
||||
|
||||
|
|
@ -20,9 +20,9 @@ class DoublerService
|
|||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct(AuditionCacheService $auditionCacheService, TabulationService $tabulationService, SeatingService $seatingService)
|
||||
public function __construct(AuditionService $auditionService, TabulationService $tabulationService, SeatingService $seatingService)
|
||||
{
|
||||
$this->auditionCacheService = $auditionCacheService;
|
||||
$this->auditionService = $auditionService;
|
||||
$this->tabulationService = $tabulationService;
|
||||
$this->seatingService = $seatingService;
|
||||
}
|
||||
|
|
@ -100,13 +100,13 @@ class DoublerService
|
|||
$info[$entry->id] = [
|
||||
'entryID' => $entry->id,
|
||||
'auditionID' => $entry->audition_id,
|
||||
'auditionName' => $this->auditionCacheService->getAudition($entry->audition_id)->name,
|
||||
'auditionName' => $this->auditionService->getAudition($entry->audition_id)->name,
|
||||
'rank' => $this->tabulationService->entryRank($entry),
|
||||
'unscored' => $this->tabulationService->remainingEntriesForAudition($entry->audition_id),
|
||||
'limits' => $this->seatingService->getLimitForAudition($entry->audition_id),
|
||||
'status' => $status,
|
||||
];
|
||||
$entry->audition = $this->auditionCacheService->getAudition($entry->audition_id);
|
||||
$entry->audition = $this->auditionService->getAudition($entry->audition_id);
|
||||
}
|
||||
|
||||
return $info;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use App\Models\Entry;
|
|||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class EntryCacheService
|
||||
class EntryService
|
||||
{
|
||||
protected $auditionCache;
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct(AuditionCacheService $auditionCache)
|
||||
public function __construct(AuditionService $auditionCache)
|
||||
{
|
||||
$this->auditionCache = $auditionCache;
|
||||
}
|
||||
|
|
@ -89,4 +89,13 @@ class EntryCacheService
|
|||
$this->clearEntryCacheForAudition($audition->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function entryIsLate(Entry $entry): bool
|
||||
{
|
||||
if ($entry->hasFlag('wave_late_fee')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $entry->created_at > $entry->audition->entry_deadline;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ class ScoreService
|
|||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct(AuditionCacheService $auditionCache, EntryCacheService $entryCache)
|
||||
public function __construct(AuditionService $auditionCache, EntryService $entryCache)
|
||||
{
|
||||
$this->auditionCache = $auditionCache;
|
||||
$this->entryCache = $entryCache;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ use Illuminate\Support\Facades\Session;
|
|||
|
||||
class TabulationService
|
||||
{
|
||||
protected AuditionCacheService $auditionCacheService;
|
||||
protected AuditionService $auditionService;
|
||||
|
||||
protected EntryCacheService $entryCacheService;
|
||||
protected EntryService $entryService;
|
||||
|
||||
protected ScoreService $scoreService;
|
||||
|
||||
|
|
@ -19,13 +19,13 @@ class TabulationService
|
|||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct(
|
||||
AuditionCacheService $scoringGuideCacheService,
|
||||
AuditionService $auditionService,
|
||||
ScoreService $scoreService,
|
||||
EntryCacheService $entryCacheService)
|
||||
EntryService $entryService)
|
||||
{
|
||||
$this->auditionCacheService = $scoringGuideCacheService;
|
||||
$this->auditionService = $auditionService;
|
||||
$this->scoreService = $scoreService;
|
||||
$this->entryCacheService = $entryCacheService;
|
||||
$this->entryService = $entryService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,8 +51,8 @@ class TabulationService
|
|||
return $cache[$auditionId];
|
||||
}
|
||||
|
||||
$audition = $this->auditionCacheService->getAudition($auditionId);
|
||||
$entries = $this->entryCacheService->getEntriesForAudition($auditionId, $mode);
|
||||
$audition = $this->auditionService->getAudition($auditionId);
|
||||
$entries = $this->entryService->getEntriesForAudition($auditionId, $mode);
|
||||
$this->scoreService->calculateScoresForAudition($auditionId);
|
||||
// TODO will need to pass a mode to the above function to only use subscores for hte appropriate mode
|
||||
foreach ($entries as $entry) {
|
||||
|
|
@ -91,7 +91,7 @@ class TabulationService
|
|||
public function entryScoreSheetsAreValid(Entry $entry): bool
|
||||
{
|
||||
//TODO consider making this move the invalid score to another database for further investigation
|
||||
$validJudges = $this->auditionCacheService->getAudition($entry->audition_id)->judges;
|
||||
$validJudges = $this->auditionService->getAudition($entry->audition_id)->judges;
|
||||
foreach ($entry->scoreSheets as $sheet) {
|
||||
if (! $validJudges->contains($sheet->user_id)) {
|
||||
$invalidJudge = User::find($sheet->user_id);
|
||||
|
|
@ -135,11 +135,11 @@ class TabulationService
|
|||
return Cache::remember('auditionsWithStatus', 30, function () use ($mode) {
|
||||
|
||||
// Retrieve auditions from the cache and load entry IDs
|
||||
$auditions = $this->auditionCacheService->getAuditions($mode);
|
||||
$auditions = $this->auditionService->getAuditions($mode);
|
||||
// Iterate over the auditions and calculate the scored_entries_count
|
||||
foreach ($auditions as $audition) {
|
||||
$scored_entries_count = 0;
|
||||
$entries_to_check = $this->entryCacheService->getEntriesForAudition($audition->id);
|
||||
$entries_to_check = $this->entryService->getEntriesForAudition($audition->id);
|
||||
|
||||
switch ($mode) {
|
||||
case 'seating':
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
use Illuminate\Support\Facades\Session;
|
||||
@endphp
|
||||
@inject('scoreservice','App\Services\ScoreService');
|
||||
@inject('auditionService','App\Services\AuditionCacheService');
|
||||
@inject('entryService','App\Services\EntryCacheService')
|
||||
@inject('auditionService','App\Services\AuditionService');
|
||||
@inject('entryService','App\Services\EntryService')
|
||||
@inject('seatingService','App\Services\SeatingService')
|
||||
<x-layout.app>
|
||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||
|
|
@ -22,6 +22,4 @@
|
|||
@endphp
|
||||
|
||||
|
||||
|
||||
|
||||
</x-layout.app>
|
||||
|
|
|
|||
Loading…
Reference in New Issue