Correct error in getAuditionsWithStatus function of TabulationService
This commit is contained in:
parent
2169afdb0b
commit
46d40adb6e
|
|
@ -4,7 +4,6 @@ namespace App\Services;
|
|||
|
||||
use App\Models\Audition;
|
||||
use App\Models\ScoringGuide;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
|
@ -12,6 +11,7 @@ use Illuminate\Support\Facades\Session;
|
|||
class AuditionCacheService
|
||||
{
|
||||
protected $cacheKey = 'auditions';
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
|
|
@ -23,12 +23,14 @@ class AuditionCacheService
|
|||
/**
|
||||
* Return or fill cache of auditions including the audition,
|
||||
* scoringGuide.subscores, judges, judges_count, and entries_count
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAuditions(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return Cache::remember($this->cacheKey, 3600, function () {
|
||||
if (App::environment('local')) Session::flash('success','Audition Cache Updated');
|
||||
if (App::environment('local')) {
|
||||
Session::flash('success', 'Audition Cache Updated');
|
||||
}
|
||||
|
||||
return Audition::with(['scoringGuide.subscores', 'judges'])
|
||||
->withCount('judges')
|
||||
->withCount('entries')
|
||||
|
|
@ -43,7 +45,6 @@ class AuditionCacheService
|
|||
return $this->getAuditions()->firstWhere('id', $id);
|
||||
}
|
||||
|
||||
|
||||
public function refreshCache()
|
||||
{
|
||||
Cache::forget($this->cacheKey);
|
||||
|
|
@ -52,7 +53,9 @@ class AuditionCacheService
|
|||
|
||||
public function clearCache()
|
||||
{
|
||||
if (App::environment('local')) Session::flash('success','Audition Cache Cleared');
|
||||
if (App::environment('local')) {
|
||||
Session::flash('success', 'Audition Cache Cleared');
|
||||
}
|
||||
Cache::forget($this->cacheKey);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ namespace App\Services;
|
|||
|
||||
use App\Models\SeatingLimit;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use function Pest\Laravel\get;
|
||||
|
||||
class SeatingService
|
||||
{
|
||||
protected $limitsCacheKey = 'acceptanceLimits';
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
|
|
@ -21,7 +21,13 @@ class SeatingService
|
|||
{
|
||||
// TODO modifying audition limits should refresh this cache
|
||||
return Cache::remember($this->limitsCacheKey, now()->addDay(), function () {
|
||||
return SeatingLimit::all()->groupBy('audition_id');
|
||||
$limits = SeatingLimit::with('ensemble')->get();
|
||||
// Sort limits by ensemlbe->rank
|
||||
$limits = $limits->sortBy(function ($limit) {
|
||||
return $limit->ensemble->rank;
|
||||
});
|
||||
|
||||
return $limits->groupBy('audition_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +36,8 @@ class SeatingService
|
|||
return $this->getAcceptanceLimits()[$auditionId];
|
||||
}
|
||||
|
||||
public function refershLimits() {
|
||||
public function refershLimits()
|
||||
{
|
||||
Cache::forget($this->limitsCacheKey);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class TabulationService
|
|||
foreach ($auditions as $audition) {
|
||||
$scored_entries_count = 0;
|
||||
foreach ($this->entryCacheService->getEntriesForAudition($audition->id) as $entry) {
|
||||
if ($this->scoreService->entryScoreSheetCounts()[$entry->id] ?? $audition->judges_count == 0) {
|
||||
if ($this->scoreService->entryScoreSheetCounts()[$entry->id] - $audition->judges_count == 0) {
|
||||
$scored_entries_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@
|
|||
Seating Form
|
||||
</x-card.heading>
|
||||
<div class="pl-3">
|
||||
@foreach($entries as $entry)
|
||||
@if(! $entry->scoring_complete)
|
||||
Entry {{ $entry->id }} is unscored.
|
||||
@if(! $complete)
|
||||
Unable to seat. Not all entries are scored.<br>
|
||||
@endif
|
||||
|
||||
@if(! $doublerComplete)
|
||||
Unable to seat. Not all doublers are resolved.<br>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
</x-card.card>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue