Fix entry count issue to respect for_seating and for_advancement
This commit is contained in:
parent
caf0b8b859
commit
deb6b8b680
|
|
@ -37,7 +37,7 @@ class TabulationController extends Controller
|
|||
|
||||
public function status()
|
||||
{
|
||||
$auditions = $this->tabulationService->getAuditionsWithStatus();
|
||||
$auditions = $this->tabulationService->getAuditionsWithStatus('seating');
|
||||
|
||||
return view('tabulation.status', compact('auditions'));
|
||||
}
|
||||
|
|
@ -51,6 +51,10 @@ class TabulationController extends Controller
|
|||
}
|
||||
|
||||
$entries = $this->tabulationService->auditionEntries($audition->id);
|
||||
$entries = $entries->filter(function ($entry) {
|
||||
return $entry->for_seating;
|
||||
});
|
||||
|
||||
$doublerComplete = true;
|
||||
foreach ($entries as $entry) {
|
||||
|
||||
|
|
@ -65,9 +69,13 @@ class TabulationController extends Controller
|
|||
return $entry->scoring_complete;
|
||||
});
|
||||
$ensembleLimits = $this->seatingService->getLimitForAudition($audition->id);
|
||||
// TODO die gracefully if no ensemble limits are set for this audition
|
||||
$auditionComplete = $scoringComplete && $doublerComplete;
|
||||
|
||||
$seatableEntries = $this->seatingService->getSeatableEntries($audition->id);
|
||||
$seatableEntries = $seatableEntries->filter(function ($entry) {
|
||||
return $entry->for_seating;
|
||||
});
|
||||
|
||||
return view('tabulation.auditionSeating', compact('audition',
|
||||
'entries',
|
||||
|
|
@ -97,6 +105,7 @@ class TabulationController extends Controller
|
|||
Cache::forget('resultsSeatList');
|
||||
Cache::forget('publishedAuditions');
|
||||
Cache::forget('audition'.$audition->id.'seats');
|
||||
|
||||
// TODO move the previous Cache functions here and in unplublish to the services, need to add an event for publishing an audition as well
|
||||
return redirect()->route('tabulation.audition.seat', ['audition' => $audition->id]);
|
||||
}
|
||||
|
|
@ -110,6 +119,7 @@ class TabulationController extends Controller
|
|||
Cache::forget('audition'.$audition->id.'seats');
|
||||
$this->seatingService->forgetSeatsForAudition($audition->id);
|
||||
Seat::where('audition_id', $audition->id)->delete();
|
||||
|
||||
return redirect()->route('tabulation.audition.seat', ['audition' => $audition->id]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,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;
|
||||
|
|
@ -34,6 +35,12 @@ class AuditionCacheService
|
|||
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);
|
||||
}])
|
||||
->orderBy('score_order')
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class DoublerService
|
|||
public function getDoublers(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
// TODO creating or destroying an entry should refresh the doubler cache
|
||||
// TODO this currently counts total entries, only need to count seating_entries. Would be an edge case, but needs to be fixed.
|
||||
return Cache::remember($this->doublersCacheKey, 60, function () {
|
||||
return Student::withCount('entries')
|
||||
->with('entries')
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class TabulationService
|
|||
$entry->rank = $n;
|
||||
$n++;
|
||||
} else {
|
||||
$entry->rank = $n . ' - declined';
|
||||
$entry->rank = $n.' - declined';
|
||||
}
|
||||
}
|
||||
$cache[$auditionId] = $entries->keyBy('id');
|
||||
|
|
@ -107,10 +107,16 @@ class TabulationService
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function remainingEntriesForAudition($auditionId)
|
||||
public function remainingEntriesForAudition($auditionId, $mode = 'seating')
|
||||
{
|
||||
$audition = $this->getAuditionsWithStatus()[$auditionId];
|
||||
$audition = $this->getAuditionsWithStatus($mode)[$auditionId];
|
||||
|
||||
switch ($mode) {
|
||||
case 'seating':
|
||||
return $audition->seating_entries_count - $audition->scored_entries_count;
|
||||
case 'advancement':
|
||||
return $audition->advancement_entries_count - $audition->scored_entries_count;
|
||||
}
|
||||
return $audition->entries_count - $audition->scored_entries_count;
|
||||
}
|
||||
|
||||
|
|
@ -121,17 +127,39 @@ class TabulationService
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuditionsWithStatus()
|
||||
public function getAuditionsWithStatus($mode = 'seating')
|
||||
{
|
||||
return Cache::remember('auditionsWithStatus', 30, function () {
|
||||
return Cache::remember('auditionsWithStatus', 30, function () use ($mode) {
|
||||
|
||||
// Retrieve auditions from the cache and load entry IDs
|
||||
$auditions = $this->auditionCacheService->getAuditions();
|
||||
|
||||
|
||||
// Iterate over the auditions and calculate the scored_entries_count
|
||||
foreach ($auditions as $audition) {
|
||||
$scored_entries_count = 0;
|
||||
foreach ($this->entryCacheService->getEntriesForAudition($audition->id) as $entry) {
|
||||
$entries_to_check = $this->entryCacheService->getEntriesForAudition($audition->id);
|
||||
|
||||
switch ($mode) {
|
||||
case 'seating':
|
||||
$entries_to_check = $entries_to_check->filter(function ($entry) {
|
||||
return $entry->for_seating;
|
||||
});
|
||||
$auditions = $auditions->filter(function ($audition) {
|
||||
return $audition->for_seating;
|
||||
});
|
||||
break;
|
||||
case 'advancement':
|
||||
$entries_to_check = $entries_to_check->filter(function ($entry) {
|
||||
return $entry->for_advancement;
|
||||
});
|
||||
$auditions = $auditions->filter(function ($audition) {
|
||||
return $audition->for_advancement;
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($entries_to_check as $entry) {
|
||||
if ($this->scoreService->entryScoreSheetCounts()[$entry->id] - $audition->judges_count == 0) {
|
||||
$scored_entries_count++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ return [
|
|||
'show_copy' => false, // Show copy button next to the query,
|
||||
'slow_threshold' => false, // Only track queries that last longer than this time in ms
|
||||
'memory_usage' => false, // Show queries memory usage
|
||||
'soft_limit' => 200, // After the soft limit, no parameters/backtrace are captured
|
||||
'soft_limit' => 400, // After the soft limit, no parameters/backtrace are captured
|
||||
'hard_limit' => 500, // After the hard limit, queries are ignored
|
||||
],
|
||||
'mail' => [
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@
|
|||
</button>
|
||||
|
||||
<!-- Profile dropdown -->
|
||||
<div>
|
||||
<a href="/test">TEST PAGE</a>
|
||||
</div>
|
||||
<div
|
||||
x-data="{
|
||||
open: false,
|
||||
|
|
|
|||
|
|
@ -15,19 +15,18 @@
|
|||
<x-table.body>
|
||||
@foreach($auditions as $audition)
|
||||
@php
|
||||
if($audition->entries_count > 0) {
|
||||
$percent = round(($audition->scored_entries_count / $audition->entries_count) * 100);
|
||||
|
||||
$percent = 100;
|
||||
if($audition->seating_entries_count > 0) {
|
||||
$percent = round(($audition->scored_entries_count / $audition->seating_entries_count) * 100);
|
||||
}
|
||||
@endphp
|
||||
<tr class="hover:bg-gray-50">
|
||||
|
||||
<x-table.td class="">
|
||||
<a href="/tabulation/auditions/{{ $audition->id }}">
|
||||
{{-- {{ $audition->scored_entries_count }} / {{ $audition->entries_count }} Scored--}}
|
||||
<div class="flex justify-between mb-1">
|
||||
<span class="text-base font-medium text-indigo-700 dark:text-white">{{ $audition->name }}</span>
|
||||
<span class="text-sm font-medium text-indigo-700 dark:text-white">{{ $audition->scored_entries_count }} / {{ $audition->entries_count }} Scored</span>
|
||||
<span class="text-sm font-medium text-indigo-700 dark:text-white">{{ $audition->scored_entries_count }} / {{ $audition->seating_entries_count }} Scored</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700">
|
||||
<div class="bg-indigo-600 h-2.5 rounded-full" style="width: {{ $percent }}%"></div>
|
||||
|
|
@ -35,7 +34,7 @@
|
|||
</a>
|
||||
</x-table.td>
|
||||
<td class="px-8">
|
||||
@if( $audition->scored_entries_count == $audition->entries_count)
|
||||
@if( $audition->scored_entries_count == $audition->seating_entries_count)
|
||||
<x-icons.checkmark color="green"/>
|
||||
@endif
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -18,10 +18,27 @@
|
|||
@php
|
||||
dump($auditionService->getAuditions());
|
||||
@endphp
|
||||
<x-table.table>
|
||||
<thead>
|
||||
<tr>
|
||||
<x-table.th>Name</x-table.th>
|
||||
<x-table.th>Total Entries</x-table.th>
|
||||
<x-table.th>Seating Entries</x-table.th>
|
||||
<x-table.th>Advancement Entries</x-table.th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($auditionService->getAuditions() as $a)
|
||||
<tr>
|
||||
<x-table.td>{{ $a->name }}</x-table.td>
|
||||
<x-table.td>{{ $a->entries_count }}</x-table.td>
|
||||
<x-table.td>{{ $a->seating_entries_count }}</x-table.td>
|
||||
<x-table.th>{{ $a->advancement_entries_count }}</x-table.th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</x-table.table>
|
||||
|
||||
@foreach($auditionService->getAuditions() as $a)
|
||||
{{ $a->name }} <br>
|
||||
@endforeach
|
||||
|
||||
|
||||
</x-layout.app>
|
||||
|
|
|
|||
Loading…
Reference in New Issue