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\Audition;
|
||||||
use App\Models\ScoringGuide;
|
use App\Models\ScoringGuide;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
@ -12,6 +11,7 @@ use Illuminate\Support\Facades\Session;
|
||||||
class AuditionCacheService
|
class AuditionCacheService
|
||||||
{
|
{
|
||||||
protected $cacheKey = 'auditions';
|
protected $cacheKey = 'auditions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new class instance.
|
* Create a new class instance.
|
||||||
*/
|
*/
|
||||||
|
|
@ -23,13 +23,15 @@ class AuditionCacheService
|
||||||
/**
|
/**
|
||||||
* Return or fill cache of auditions including the audition,
|
* Return or fill cache of auditions including the audition,
|
||||||
* scoringGuide.subscores, judges, judges_count, and entries_count
|
* scoringGuide.subscores, judges, judges_count, and entries_count
|
||||||
* @return Collection
|
|
||||||
*/
|
*/
|
||||||
public function getAuditions(): \Illuminate\Database\Eloquent\Collection
|
public function getAuditions(): \Illuminate\Database\Eloquent\Collection
|
||||||
{
|
{
|
||||||
return Cache::remember($this->cacheKey, 3600, function () {
|
return Cache::remember($this->cacheKey, 3600, function () {
|
||||||
if (App::environment('local')) Session::flash('success','Audition Cache Updated');
|
if (App::environment('local')) {
|
||||||
return Audition::with(['scoringGuide.subscores','judges'])
|
Session::flash('success', 'Audition Cache Updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Audition::with(['scoringGuide.subscores', 'judges'])
|
||||||
->withCount('judges')
|
->withCount('judges')
|
||||||
->withCount('entries')
|
->withCount('entries')
|
||||||
->orderBy('score_order')
|
->orderBy('score_order')
|
||||||
|
|
@ -40,10 +42,9 @@ class AuditionCacheService
|
||||||
|
|
||||||
public function getAudition($id): Audition
|
public function getAudition($id): Audition
|
||||||
{
|
{
|
||||||
return $this->getAuditions()->firstWhere('id',$id);
|
return $this->getAuditions()->firstWhere('id', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function refreshCache()
|
public function refreshCache()
|
||||||
{
|
{
|
||||||
Cache::forget($this->cacheKey);
|
Cache::forget($this->cacheKey);
|
||||||
|
|
@ -52,7 +53,9 @@ class AuditionCacheService
|
||||||
|
|
||||||
public function clearCache()
|
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);
|
Cache::forget($this->cacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Models\SeatingLimit;
|
use App\Models\SeatingLimit;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use function Pest\Laravel\get;
|
|
||||||
|
|
||||||
class SeatingService
|
class SeatingService
|
||||||
{
|
{
|
||||||
protected $limitsCacheKey = 'acceptanceLimits';
|
protected $limitsCacheKey = 'acceptanceLimits';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new class instance.
|
* Create a new class instance.
|
||||||
*/
|
*/
|
||||||
|
|
@ -21,7 +21,13 @@ class SeatingService
|
||||||
{
|
{
|
||||||
// TODO modifying audition limits should refresh this cache
|
// TODO modifying audition limits should refresh this cache
|
||||||
return Cache::remember($this->limitsCacheKey, now()->addDay(), function () {
|
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];
|
return $this->getAcceptanceLimits()[$auditionId];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refershLimits() {
|
public function refershLimits()
|
||||||
|
{
|
||||||
Cache::forget($this->limitsCacheKey);
|
Cache::forget($this->limitsCacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ class TabulationService
|
||||||
foreach ($auditions as $audition) {
|
foreach ($auditions as $audition) {
|
||||||
$scored_entries_count = 0;
|
$scored_entries_count = 0;
|
||||||
foreach ($this->entryCacheService->getEntriesForAudition($audition->id) as $entry) {
|
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++;
|
$scored_entries_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,13 @@
|
||||||
Seating Form
|
Seating Form
|
||||||
</x-card.heading>
|
</x-card.heading>
|
||||||
<div class="pl-3">
|
<div class="pl-3">
|
||||||
@foreach($entries as $entry)
|
@if(! $complete)
|
||||||
@if(! $entry->scoring_complete)
|
Unable to seat. Not all entries are scored.<br>
|
||||||
Entry {{ $entry->id }} is unscored.
|
@endif
|
||||||
@endif
|
|
||||||
@endforeach
|
@if(! $doublerComplete)
|
||||||
|
Unable to seat. Not all doublers are resolved.<br>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue