Showing doublers working
This commit is contained in:
parent
719b4054d8
commit
b2bb3654ff
|
|
@ -6,6 +6,7 @@ use App\Actions\Tabulation\CalculateEntryScore;
|
||||||
use App\Actions\Tabulation\RankAuditionEntries;
|
use App\Actions\Tabulation\RankAuditionEntries;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
|
use App\Services\AuditionService;
|
||||||
use App\Services\DoublerService;
|
use App\Services\DoublerService;
|
||||||
use App\Services\EntryService;
|
use App\Services\EntryService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -21,16 +22,20 @@ class SeatAuditionController extends Controller
|
||||||
|
|
||||||
protected EntryService $entryService;
|
protected EntryService $entryService;
|
||||||
|
|
||||||
|
protected AuditionService $auditionService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CalculateEntryScore $calc,
|
CalculateEntryScore $calc,
|
||||||
RankAuditionEntries $ranker,
|
RankAuditionEntries $ranker,
|
||||||
DoublerService $doublerService,
|
DoublerService $doublerService,
|
||||||
EntryService $entryService
|
EntryService $entryService,
|
||||||
|
AuditionService $auditionService,
|
||||||
) {
|
) {
|
||||||
$this->calc = $calc;
|
$this->calc = $calc;
|
||||||
$this->ranker = $ranker;
|
$this->ranker = $ranker;
|
||||||
$this->doublerService = $doublerService;
|
$this->doublerService = $doublerService;
|
||||||
$this->entryService = $entryService;
|
$this->entryService = $entryService;
|
||||||
|
$this->auditionService = $auditionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(Request $request, Audition $audition)
|
public function __invoke(Request $request, Audition $audition)
|
||||||
|
|
@ -46,13 +51,20 @@ class SeatAuditionController extends Controller
|
||||||
$isDoubler = true;
|
$isDoubler = true;
|
||||||
$doubleData = [];
|
$doubleData = [];
|
||||||
$doublerEntries = $doublers[$entry->student->id]['entries'];
|
$doublerEntries = $doublers[$entry->student->id]['entries'];
|
||||||
|
|
||||||
foreach ($doublerEntries as $doublerEntry) {
|
foreach ($doublerEntries as $doublerEntry) {
|
||||||
Log::debug('doubler check for entry ' . $doublerEntry->id);
|
$limits = $this->auditionService->getSeatingLimits($doublerEntry->audition);
|
||||||
log::debug('Rank: ' . $this->entryService->rankOfEntry('seating', $doublerEntry));
|
$limits = $limits->reject(function ($lim) {
|
||||||
|
return $lim['limit'] === 0;
|
||||||
|
});
|
||||||
$doubleData[] = [
|
$doubleData[] = [
|
||||||
|
'audition' => $doublerEntry->audition,
|
||||||
'name' => $doublerEntry->audition->name,
|
'name' => $doublerEntry->audition->name,
|
||||||
'entryId' => $doublerEntry->id,
|
'entryId' => $doublerEntry->id,
|
||||||
'rank' => $this->entryService->rankOfEntry('seating', $doublerEntry),
|
'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);
|
User::observe(UserObserver::class);
|
||||||
SeatingLimit::observe(SeatingLimitObserver::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\Exceptions\AuditionServiceException;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
|
use App\Models\Ensemble;
|
||||||
|
use App\Models\SeatingLimit;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
|
@ -43,37 +45,11 @@ class AuditionService
|
||||||
'advancement' => 'for_advance',
|
'advancement' => 'for_advance',
|
||||||
};
|
};
|
||||||
$audition->load('scoringGuide.subscores');
|
$audition->load('scoringGuide.subscores');
|
||||||
|
|
||||||
return $audition->scoringGuide->subscores->where($modeColumn, true)->sortBy($sortColumn);
|
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)
|
public function getJudgesOLD(Audition $audition)
|
||||||
{
|
{
|
||||||
$cacheKey = 'auditionJudges-'.$audition->id;
|
$cacheKey = 'auditionJudges-'.$audition->id;
|
||||||
|
|
@ -101,6 +77,38 @@ class AuditionService
|
||||||
return $assignments[$audition->id];
|
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)
|
protected function validateAudition($audition)
|
||||||
{
|
{
|
||||||
if (! $audition->exists()) {
|
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')
|
@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="">
|
<ul role="list" class="">
|
||||||
|
|
||||||
@foreach($doublerEntryInfo as $info)
|
@foreach($entry['doubleData'] as $double)
|
||||||
@php($isopen = $info['status'] == 'undecided')
|
@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' }} }">
|
<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" >
|
<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">
|
<p class="text-sm font-semibold leading-6 text-gray-900">
|
||||||
<a href="/tabulation/auditions/{{ $info['auditionID'] }}">
|
{{-- TODO put in link --}}
|
||||||
{{ $info['auditionName'] }} - {{ $info['status'] }}
|
<a href="{{ route('seating.audition', $double['audition']) }}">
|
||||||
|
{{ $double['name'] }} - {{ $double['status'] }}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<div class="w-full flex justify-end" >
|
<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">
|
<div class="mt-1 px-3 text-xs leading-5 text-gray-500 col-span-3">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="flex items-center gap-x-2">
|
<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">
|
<svg viewBox="0 0 2 2" class="h-0.5 w-0.5 fill-current">
|
||||||
<circle cx="1" cy="1" r="1" />
|
<circle cx="1" cy="1" r="1" />
|
||||||
</svg>
|
</svg>
|
||||||
<p class="truncate">{{ $info['unscored'] }} Unscored</p>
|
<p class="truncate">{{ $double['unscored_in_audition'] }} Unscored</p>
|
||||||
</li>
|
</li>
|
||||||
@foreach($info['limits'] as $limit)
|
@foreach($double['limits'] as $limit)
|
||||||
<li>{{ $limit->ensemble->name }} accepts {{ $limit->maximum_accepted }}</li>
|
<li>{{$limit['ensemble']->name}} accepts {{ $limit['limit'] }}</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col justify-end gap-y-1 pt-1">
|
<div class="flex flex-col justify-end gap-y-1 pt-1">
|
||||||
@if ($info['status'] === 'undecided')
|
@if ($double['status'] == 'undecided')
|
||||||
<form method="POST" action="{{ route('doubler.accept',['entry'=>$info['entryID']]) }}">
|
<form method="POST" action="{{ route('doubler.accept',['entry'=>$double['entryId']]) }}">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="{{ $doublerButtonClasses }}">Accept</button>
|
<button class="{{ $doublerButtonClasses }}">Accept</button>
|
||||||
</form>
|
</form>
|
||||||
<form method="POST" action="{{ route('doubler.decline',['entry'=>$info['entryID']]) }}">
|
<form method="POST" action="{{ route('doubler.decline',['entry'=>$double['entryId']]) }}">
|
||||||
@csrf
|
@csrf
|
||||||
<button class="{{ $doublerButtonClasses }}">Decline</button>
|
<button class="{{ $doublerButtonClasses }}">Decline</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,16 @@
|
||||||
</x-table.td>
|
</x-table.td>
|
||||||
<x-table.td class="!py-0">
|
<x-table.td class="!py-0">
|
||||||
@if($entry['isDoubler'])
|
@if($entry['isDoubler'])
|
||||||
DOUBLER<br>
|
@include('tabulation.auditionSeating-doubler-block')
|
||||||
@foreach($entry['doubleData'] as $double)
|
{{-- DOUBLER<br>--}}
|
||||||
ID: {{ $double['entryId'] }} - {{ $double['name'] }} - {{ $double['rank'] }}<br>
|
{{-- @foreach($entry['doubleData'] as $double)--}}
|
||||||
@endforeach
|
{{-- 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
|
@endif
|
||||||
{{-- @if($doublerService->studentIsDoubler($entry->student_id))--}}
|
{{-- @if($doublerService->studentIsDoubler($entry->student_id))--}}
|
||||||
{{-- @include('tabulation.auditionSeating-doubler-block')--}}
|
{{-- @include('tabulation.auditionSeating-doubler-block')--}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue