Rewrite tabulation #14
|
|
@ -6,6 +6,7 @@ use App\Actions\Tabulation\CalculateEntryScore;
|
|||
use App\Actions\Tabulation\RankAuditionEntries;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Audition;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\DoublerService;
|
||||
use App\Services\EntryService;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -21,16 +22,20 @@ class SeatAuditionController extends Controller
|
|||
|
||||
protected EntryService $entryService;
|
||||
|
||||
protected AuditionService $auditionService;
|
||||
|
||||
public function __construct(
|
||||
CalculateEntryScore $calc,
|
||||
RankAuditionEntries $ranker,
|
||||
DoublerService $doublerService,
|
||||
EntryService $entryService
|
||||
EntryService $entryService,
|
||||
AuditionService $auditionService,
|
||||
) {
|
||||
$this->calc = $calc;
|
||||
$this->ranker = $ranker;
|
||||
$this->doublerService = $doublerService;
|
||||
$this->entryService = $entryService;
|
||||
$this->auditionService = $auditionService;
|
||||
}
|
||||
|
||||
public function __invoke(Request $request, Audition $audition)
|
||||
|
|
@ -46,13 +51,20 @@ class SeatAuditionController extends Controller
|
|||
$isDoubler = true;
|
||||
$doubleData = [];
|
||||
$doublerEntries = $doublers[$entry->student->id]['entries'];
|
||||
|
||||
foreach ($doublerEntries as $doublerEntry) {
|
||||
Log::debug('doubler check for entry ' . $doublerEntry->id);
|
||||
log::debug('Rank: ' . $this->entryService->rankOfEntry('seating', $doublerEntry));
|
||||
$limits = $this->auditionService->getSeatingLimits($doublerEntry->audition);
|
||||
$limits = $limits->reject(function ($lim) {
|
||||
return $lim['limit'] === 0;
|
||||
});
|
||||
$doubleData[] = [
|
||||
'audition' => $doublerEntry->audition,
|
||||
'name' => $doublerEntry->audition->name,
|
||||
'entryId' => $doublerEntry->id,
|
||||
'rank' => $this->entryService->rankOfEntry('seating', $doublerEntry),
|
||||
'limits' => $limits,
|
||||
'status' => 'undecided', // Will be undecided, accepted, or declined
|
||||
'unscored_in_audition' => $doublerEntry->audition->unscoredEntries()->count(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
User::observe(UserObserver::class);
|
||||
SeatingLimit::observe(SeatingLimitObserver::class);
|
||||
|
||||
Model::preventLazyLoading(! app()->isProduction());
|
||||
//Model::preventLazyLoading(! app()->isProduction());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ namespace App\Services;
|
|||
|
||||
use App\Exceptions\AuditionServiceException;
|
||||
use App\Models\Audition;
|
||||
use App\Models\Ensemble;
|
||||
use App\Models\SeatingLimit;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
|
|
@ -43,37 +45,11 @@ class AuditionService
|
|||
'advancement' => 'for_advance',
|
||||
};
|
||||
$audition->load('scoringGuide.subscores');
|
||||
|
||||
return $audition->scoringGuide->subscores->where($modeColumn, true)->sortBy($sortColumn);
|
||||
});
|
||||
}
|
||||
|
||||
public function getSubscoresNEW(Audition $audition, $mode = 'seating', $sort = 'tiebreak')
|
||||
{
|
||||
$this->validateMode($mode);
|
||||
$this->validateSort($sort);
|
||||
$cacheKey = 'auditionSubscores-'.$mode.'-'.$sort;
|
||||
$assignments = Cache::remember($cacheKey, 60, function () use ($audition, $mode, $sort) {
|
||||
$this->validateAudition($audition);
|
||||
$sortColumn = match ($sort) {
|
||||
'tiebreak' => 'tiebreak_order',
|
||||
'display' => 'display_order',
|
||||
};
|
||||
$modeColumn = match ($mode) {
|
||||
'seating' => 'for_seating',
|
||||
'advancement' => 'for_advance',
|
||||
};
|
||||
$allAuditions = Audition::with(['scoringGuide.subscores' => function ($query) use ($modeColumn, $sortColumn) {
|
||||
$query->where($modeColumn, 1)->orderBy($sortColumn);
|
||||
}])->get();
|
||||
$return = [];
|
||||
foreach ( $allAuditions as $audition) {
|
||||
$return[$audition->id] = $audition->scoringGuide->subscores;
|
||||
}
|
||||
return $return;
|
||||
});
|
||||
return $assignments[$audition->id];
|
||||
}
|
||||
|
||||
public function getJudgesOLD(Audition $audition)
|
||||
{
|
||||
$cacheKey = 'auditionJudges-'.$audition->id;
|
||||
|
|
@ -101,6 +77,38 @@ class AuditionService
|
|||
return $assignments[$audition->id];
|
||||
}
|
||||
|
||||
public function getSeatingLimits(Audition $audition)
|
||||
{
|
||||
$cacheKey = 'auditionSeatingLimits';
|
||||
$allLimits = Cache::remember($cacheKey, 60, function () {
|
||||
$lims = [];
|
||||
$auditions = Audition::all();
|
||||
$ensembles = Ensemble::orderBy('rank')->get();
|
||||
foreach ($auditions as $audition) {
|
||||
foreach ($ensembles as $ensemble) {
|
||||
if ($ensemble->event_id !== $audition->event_id) {
|
||||
continue;
|
||||
}
|
||||
$lims[$audition->id][$ensemble->id] = [
|
||||
'ensemble' => $ensemble,
|
||||
'limit' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
$limits = SeatingLimit::all();
|
||||
|
||||
foreach ($limits as $limit) {
|
||||
$lims[$limit->audition_id][$limit->ensemble_id] = collect([
|
||||
'ensemble' => $ensembles->find($limit->ensemble_id),
|
||||
'limit' =>$limit->maximum_accepted,
|
||||
]);
|
||||
}
|
||||
return collect($lims);
|
||||
});
|
||||
|
||||
return collect($allLimits[$audition->id]) ?? [];
|
||||
}
|
||||
|
||||
protected function validateAudition($audition)
|
||||
{
|
||||
if (! $audition->exists()) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
@php($doublerEntryInfo = $doublerService->getDoublerInfo($entry->student_id))
|
||||
@php($doublerButtonClasses = 'hidden rounded-md bg-white px-2.5 py-1.5 text-xs text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:block')
|
||||
<ul role="list" class="">
|
||||
|
||||
@foreach($doublerEntryInfo as $info)
|
||||
@php($isopen = $info['status'] == 'undecided')
|
||||
@foreach($entry['doubleData'] as $double)
|
||||
@php($isopen = $double['status'] == 'undecided')
|
||||
<li class="pb-2 pt-0 px-0 my-2 rounded-xl border border-gray-200 max-w-xs" x-data="{ open: {{ $isopen ? 'true':'false' }} }">
|
||||
<div class="flex items-start gap-x-3 bg-gray-100 px-3 py-2 rounded-t-xl" >
|
||||
<p class="text-sm font-semibold leading-6 text-gray-900">
|
||||
<a href="/tabulation/auditions/{{ $info['auditionID'] }}">
|
||||
{{ $info['auditionName'] }} - {{ $info['status'] }}
|
||||
{{-- TODO put in link --}}
|
||||
<a href="{{ route('seating.audition', $double['audition']) }}">
|
||||
{{ $double['name'] }} - {{ $double['status'] }}
|
||||
</a>
|
||||
</p>
|
||||
<div class="w-full flex justify-end" >
|
||||
|
|
@ -22,25 +22,25 @@
|
|||
<div class="mt-1 px-3 text-xs leading-5 text-gray-500 col-span-3">
|
||||
<ul>
|
||||
<li class="flex items-center gap-x-2">
|
||||
<p class="whitespace-nowrap">Ranked {{ $info['rank'] }}</p>
|
||||
<p class="whitespace-nowrap">Ranked {{ $double['rank'] }}</p>
|
||||
<svg viewBox="0 0 2 2" class="h-0.5 w-0.5 fill-current">
|
||||
<circle cx="1" cy="1" r="1" />
|
||||
</svg>
|
||||
<p class="truncate">{{ $info['unscored'] }} Unscored</p>
|
||||
<p class="truncate">{{ $double['unscored_in_audition'] }} Unscored</p>
|
||||
</li>
|
||||
@foreach($info['limits'] as $limit)
|
||||
<li>{{ $limit->ensemble->name }} accepts {{ $limit->maximum_accepted }}</li>
|
||||
@foreach($double['limits'] as $limit)
|
||||
<li>{{$limit['ensemble']->name}} accepts {{ $limit['limit'] }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col justify-end gap-y-1 pt-1">
|
||||
@if ($info['status'] === 'undecided')
|
||||
<form method="POST" action="{{ route('doubler.accept',['entry'=>$info['entryID']]) }}">
|
||||
@if ($double['status'] == 'undecided')
|
||||
<form method="POST" action="{{ route('doubler.accept',['entry'=>$double['entryId']]) }}">
|
||||
@csrf
|
||||
<button class="{{ $doublerButtonClasses }}">Accept</button>
|
||||
</form>
|
||||
<form method="POST" action="{{ route('doubler.decline',['entry'=>$info['entryID']]) }}">
|
||||
<form method="POST" action="{{ route('doubler.decline',['entry'=>$double['entryId']]) }}">
|
||||
@csrf
|
||||
<button class="{{ $doublerButtonClasses }}">Decline</button>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -27,10 +27,16 @@
|
|||
</x-table.td>
|
||||
<x-table.td class="!py-0">
|
||||
@if($entry['isDoubler'])
|
||||
DOUBLER<br>
|
||||
@foreach($entry['doubleData'] as $double)
|
||||
ID: {{ $double['entryId'] }} - {{ $double['name'] }} - {{ $double['rank'] }}<br>
|
||||
@endforeach
|
||||
@include('tabulation.auditionSeating-doubler-block')
|
||||
{{-- DOUBLER<br>--}}
|
||||
{{-- @foreach($entry['doubleData'] as $double)--}}
|
||||
{{-- ID: {{ $double['entryId'] }} - {{ $double['name'] }} - {{ $double['rank'] }}<br>--}}
|
||||
{{-- Unscored Entries: {{ $double['unscored_in_audition'] }}<br>--}}
|
||||
{{-- @foreach($double['limits'] as $limit)--}}
|
||||
{{-- {{$limit['ensemble']->name}}: {{ $limit['limit'] }}<br>--}}
|
||||
{{-- @endforeach--}}
|
||||
{{-- <hr>--}}
|
||||
{{-- @endforeach--}}
|
||||
@endif
|
||||
{{-- @if($doublerService->studentIsDoubler($entry->student_id))--}}
|
||||
{{-- @include('tabulation.auditionSeating-doubler-block')--}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue