Bugfix, work on advancement ranking
This commit is contained in:
parent
9f2c084fa2
commit
1d61f5a48c
|
|
@ -13,7 +13,9 @@ use Illuminate\Support\Facades\Cache;
|
|||
class AllJudgesCount implements CalculateEntryScore
|
||||
{
|
||||
protected CalculateScoreSheetTotal $calculator;
|
||||
|
||||
protected AuditionService $auditionService;
|
||||
|
||||
protected EntryService $entryService;
|
||||
|
||||
public function __construct(CalculateScoreSheetTotal $calculator, AuditionService $auditionService, EntryService $entryService)
|
||||
|
|
@ -27,6 +29,7 @@ class AllJudgesCount implements CalculateEntryScore
|
|||
{
|
||||
|
||||
$cacheKey = 'entryScore-'.$entry->id.'-'.$mode;
|
||||
|
||||
return Cache::remember($cacheKey, 10, function () use ($mode, $entry) {
|
||||
$this->basicValidation($mode, $entry);
|
||||
$this->areAllJudgesIn($entry);
|
||||
|
|
@ -54,6 +57,7 @@ class AllJudgesCount implements CalculateEntryScore
|
|||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
return $sums;
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +82,8 @@ class AllJudgesCount implements CalculateEntryScore
|
|||
|
||||
protected function areAllJudgesValid(Entry $entry): void
|
||||
{
|
||||
$validJudgeIds = $this->auditionService->getJudges($entry->audition)->sort()->pluck('id')->toArray();
|
||||
$existingJudgeIds = $entry->scoreSheets->sort()->pluck('user_id')->toArray();
|
||||
$validJudgeIds = $this->auditionService->getJudges($entry->audition)->pluck('id')->sort()->toArray();
|
||||
$existingJudgeIds = $entry->scoreSheets->pluck('user_id')->sort()->toArray();
|
||||
if ($validJudgeIds !== $existingJudgeIds) {
|
||||
throw new TabulationException('Score exists from a judge not assigned to this audition');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Models\Entry;
|
|||
use App\Services\AuditionService;
|
||||
use App\Services\EntryService;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function auditionSetting;
|
||||
|
||||
|
|
@ -124,9 +125,12 @@ class AllowForOlympicScoring implements CalculateEntryScore
|
|||
|
||||
protected function areAllJudgesValid(Entry $entry): void
|
||||
{
|
||||
$validJudgeIds = $this->auditionService->getJudges($entry->audition)->sort()->pluck('id')->toArray();
|
||||
$existingJudgeIds = $entry->scoreSheets->sort()->pluck('user_id')->toArray();
|
||||
if ($validJudgeIds !== $existingJudgeIds) {
|
||||
$validJudgeIds = $this->auditionService->getJudges($entry->audition)->pluck('id')->toArray();
|
||||
$existingJudgeIds = $entry->scoreSheets->pluck('user_id')->toArray();
|
||||
if (array_diff($existingJudgeIds, $validJudgeIds)) {
|
||||
Log::debug('EntryID: '.$entry->id);
|
||||
Log::debug('Valid judge ids: ('.gettype($validJudgeIds).') '.json_encode($validJudgeIds));
|
||||
Log::debug('Existing judge ids: ('.gettype($existingJudgeIds).') '.json_encode($existingJudgeIds));
|
||||
throw new TabulationException('Score exists from a judge not assigned to this audition');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Audition;
|
||||
use App\Models\Ensemble;
|
||||
use App\Models\Entry;
|
||||
use App\Models\Seat;
|
||||
use App\Services\AuditionService;
|
||||
use App\Services\SeatingService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
|
|
@ -13,12 +14,9 @@ class ResultsPage extends Controller
|
|||
{
|
||||
protected $auditionService;
|
||||
|
||||
protected $seatingService;
|
||||
|
||||
public function __construct(AuditionService $auditionService, SeatingService $seatingService)
|
||||
public function __construct(AuditionService $auditionService)
|
||||
{
|
||||
$this->auditionService = $auditionService;
|
||||
$this->seatingService = $seatingService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,14 +24,18 @@ class ResultsPage extends Controller
|
|||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$publishedAuditions = $this->auditionService->getPublishedAuditions();
|
||||
$publishedAuditions = Audition::seatsPublished()
|
||||
->with('seats.ensemble')
|
||||
->with('seats.entry.student')
|
||||
->with('event.ensembles')
|
||||
->orderBy('score_order')->get();
|
||||
$resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) {
|
||||
$seatList = [];
|
||||
// Load the $seatList in the form of $seatlist[audition_id] is an array of seats for that audition
|
||||
// each $seatList[audition_id][] will contain a string with ensemble and seat number and the student object filling it
|
||||
foreach ($publishedAuditions as $audition) {
|
||||
$seats = $this->seatingService->getSeatsForAudition($audition->id);
|
||||
$ensembles = $this->seatingService->getEnsemblesForEvent($audition->event_id);
|
||||
$seats = $audition->seats->groupBy('ensemble_id');
|
||||
$ensembles = $audition->event->ensembles;
|
||||
foreach ($ensembles as $ensemble) {
|
||||
if (! $seats->has($ensemble->id)) { // If there are no students seated in this ensemble, skip it
|
||||
continue;
|
||||
|
|
@ -51,24 +53,24 @@ class ResultsPage extends Controller
|
|||
return $seatList;
|
||||
});
|
||||
|
||||
$publishedAdvancementAuditions = $this->auditionService->getPublishedAdvancementAuditions();
|
||||
$resultsAdvancementList = Cache::rememberForever('resultsAdvancementList', function () use ($publishedAdvancementAuditions) {
|
||||
$qualifierList = [];
|
||||
foreach ($publishedAdvancementAuditions as $audition) {
|
||||
$qualifierList[$audition->id] = Entry::with('flags', 'student.school')
|
||||
->where('audition_id', $audition->id)
|
||||
->where('for_advancement', true)
|
||||
->get()->filter(function (Entry $entry) {
|
||||
return $entry->hasFlag('will_advance');
|
||||
})
|
||||
->sortBy(function (Entry $entry) {
|
||||
return $entry->student->full_name(true);
|
||||
});
|
||||
}
|
||||
// $publishedAdvancementAuditions = $this->auditionService->getPublishedAdvancementAuditions();
|
||||
// $resultsAdvancementList = Cache::rememberForever('resultsAdvancementList', function () use ($publishedAdvancementAuditions) {
|
||||
// $qualifierList = [];
|
||||
// foreach ($publishedAdvancementAuditions as $audition) {
|
||||
// $qualifierList[$audition->id] = Entry::with('flags', 'student.school')
|
||||
// ->where('audition_id', $audition->id)
|
||||
// ->where('for_advancement', true)
|
||||
// ->get()->filter(function (Entry $entry) {
|
||||
// return $entry->hasFlag('will_advance');
|
||||
// })
|
||||
// ->sortBy(function (Entry $entry) {
|
||||
// return $entry->student->full_name(true);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// return $qualifierList;
|
||||
// });
|
||||
|
||||
return $qualifierList;
|
||||
});
|
||||
|
||||
return view('results.index', compact('publishedAuditions', 'resultsSeatList', 'resultsAdvancementList', 'publishedAdvancementAuditions'));
|
||||
return view('results.index', compact('publishedAuditions', 'resultsSeatList'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@ class Audition extends Model
|
|||
$this->load('flags');
|
||||
}
|
||||
|
||||
public function seats(): HasMany
|
||||
{
|
||||
return $this->hasMany(Seat::class);
|
||||
}
|
||||
|
||||
public function scopeOpen(Builder $query): void
|
||||
{
|
||||
$query->where('entry_deadline', '>=', Carbon::now());
|
||||
|
|
|
|||
|
|
@ -13,20 +13,21 @@
|
|||
</x-results.table-audition-section>
|
||||
@endforeach
|
||||
</div>
|
||||
@if( auditionSetting('advanceTo') )
|
||||
<div class="h-full overflow-y-auto w-full">
|
||||
<h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('advanceTo') }} Qualifiers</h3>
|
||||
@foreach($publishedAdvancementAuditions as $audition)
|
||||
<x-results.table-audition-section :auditionName="$audition->name">
|
||||
@foreach($resultsAdvancementList[$audition->id] as $entry)
|
||||
<x-results.table-qualifier-row
|
||||
:student_name="$entry->student->full_name()"
|
||||
:school="$entry->student->school->name" />
|
||||
@endforeach
|
||||
</x-results.table-audition-section>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- @if( auditionSetting('advanceTo') )--}}
|
||||
{{-- <div class="h-full overflow-y-auto w-full">--}}
|
||||
{{-- <h3 class="pb-3 pl-2 font-semibold text-lg">{{ auditionSetting('advanceTo') }} Qualifiers</h3>--}}
|
||||
{{-- @foreach($publishedAdvancementAuditions as $audition)--}}
|
||||
{{-- <x-results.table-audition-section :auditionName="$audition->name">--}}
|
||||
{{-- @foreach($resultsAdvancementList[$audition->id] as $entry)--}}
|
||||
{{-- <x-results.table-qualifier-row--}}
|
||||
{{-- :student_name="$entry->student->full_name()"--}}
|
||||
{{-- :school="$entry->student->school->name" />--}}
|
||||
{{-- @endforeach--}}
|
||||
{{-- </x-results.table-audition-section>--}}
|
||||
{{-- @endforeach--}}
|
||||
{{-- </div>--}}
|
||||
{{-- @endif--}}
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ require __DIR__.'/user.php';
|
|||
|
||||
Route::get('/test', [TestController::class, 'flashTest'])->middleware('auth', 'verified');
|
||||
|
||||
Route::view('/home', 'welcome')->middleware('guest')->name('home');
|
||||
Route::view('/', 'landing')->name('landing');
|
||||
Route::view('/home', 'welcome')->middleware('guest')->name('landing');
|
||||
Route::view('/', 'landing')->name('home');
|
||||
Route::get('/results', [App\Http\Controllers\ResultsPage::class, '__invoke'])->name('results');
|
||||
|
||||
// Filter Related Routes
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ uses(RefreshDatabase::class);
|
|||
|
||||
it('shows appropriate screens when not logged in', function () {
|
||||
// Act & Assert
|
||||
get(route('home'))
|
||||
get(route('landing'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText([
|
||||
'Login',
|
||||
|
|
|
|||
Loading…
Reference in New Issue