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