Table of those that shoudl be accepted working. Have a cache issue with doubler choices

This commit is contained in:
Matt Young 2024-06-22 01:55:02 -05:00
parent 91e92a3aa2
commit a8db4832ce
4 changed files with 68 additions and 38 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Tabulation;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Audition; use App\Models\Audition;
use App\Services\DoublerService; use App\Services\DoublerService;
use App\Services\SeatingService;
use App\Services\TabulationService; use App\Services\TabulationService;
use function compact; use function compact;
@ -12,13 +13,14 @@ use function compact;
class TabulationController extends Controller class TabulationController extends Controller
{ {
protected $tabulationService; protected $tabulationService;
protected $doublerService; protected $doublerService;
protected $seatingService;
public function __construct(TabulationService $tabulationService, DoublerService $doublerService) public function __construct(TabulationService $tabulationService, DoublerService $doublerService, SeatingService $seatingService)
{ {
$this->tabulationService = $tabulationService; $this->tabulationService = $tabulationService;
$this->doublerService = $doublerService; $this->doublerService = $doublerService;
$this->seatingService = $seatingService;
} }
public function status() public function status()
@ -45,10 +47,12 @@ class TabulationController extends Controller
} }
} }
$complete = $entries->every(function ($entry) { $scoringComplete = $entries->every(function ($entry) {
return $entry->scoring_complete; return $entry->scoring_complete;
}); });
$ensembleLimits = $this->seatingService->getLimitForAudition($audition->id);
$auditionComplete = $scoringComplete && $doublerComplete;
return view('tabulation.auditionSeating', compact('audition', 'entries', 'complete', 'doublerComplete')); return view('tabulation.auditionSeating', compact('audition', 'entries', 'scoringComplete', 'doublerComplete', 'auditionComplete', 'ensembleLimits'));
} }
} }

View File

@ -2,26 +2,27 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use phpDocumentor\Reflection\Types\Boolean;
use PhpParser\Node\Scalar\String_;
use function now; use function now;
class Audition extends Model class Audition extends Model
{ {
use HasFactory; use HasFactory;
protected $guarded = [];
protected $rankedEntries = null;
protected static $completeAuditions = null;
protected $fully_scored; // Set by TabulationService
protected $scored_entries_count; //Set by TabulationService
protected $guarded = [];
protected $rankedEntries = null;
protected static $completeAuditions = null;
protected $fully_scored; // Set by TabulationService
protected $scored_entries_count; //Set by TabulationService
public static function deadlineNotPast() public static function deadlineNotPast()
{ {
@ -38,7 +39,6 @@ class Audition extends Model
return $this->hasMany(Entry::class); return $this->hasMany(Entry::class);
} }
public function room(): BelongsTo public function room(): BelongsTo
{ {
return $this->belongsTo(Room::class); return $this->belongsTo(Room::class);
@ -49,9 +49,9 @@ class Audition extends Model
return $this->belongsTo(ScoringGuide::class); return $this->belongsTo(ScoringGuide::class);
} }
public function dislpay_fee(): String public function dislpay_fee(): string
{ {
return '$' . number_format($this->entry_fee / 100, 2); return '$'.number_format($this->entry_fee / 100, 2);
} }
public function has_no_draw(): bool public function has_no_draw(): bool
@ -82,7 +82,7 @@ class Audition extends Model
} }
if ($this->relationLoaded('entries')) { if ($this->relationLoaded('entries')) {
return $this->entries->every(function ($entry) { return $this->entries->every(function ($entry) {
return !is_null($entry->draw_number); return ! is_null($entry->draw_number);
}); });
} else { } else {
return $this->entries()->whereNull('draw_number')->doesntExist(); return $this->entries()->whereNull('draw_number')->doesntExist();
@ -107,13 +107,14 @@ class Audition extends Model
}); });
$hasNotNull = $this->entries->contains(function ($entry) { $hasNotNull = $this->entries->contains(function ($entry) {
return !is_null($entry->draw_number); return ! is_null($entry->draw_number);
}); });
return $hasNull && $hasNotNull; return $hasNull && $hasNotNull;
} else { } else {
$hasNull = $this->entries()->whereNull('draw_number')->exists(); $hasNull = $this->entries()->whereNull('draw_number')->exists();
$hasNotNull = $this->entries()->whereNotNull('draw_number')->exists(); $hasNotNull = $this->entries()->whereNotNull('draw_number')->exists();
return $hasNull && $hasNotNull; return $hasNull && $hasNotNull;
} }
} }
@ -126,6 +127,7 @@ class Audition extends Model
$entry->update(['draw_number' => $index + 1]); $entry->update(['draw_number' => $index + 1]);
$entry->save(); $entry->save();
} }
return null; return null;
// TODO move all draw functions to a DrawService // TODO move all draw functions to a DrawService
} }
@ -133,7 +135,7 @@ class Audition extends Model
/** /**
* @return BelongsToMany|\App\Models\User[] * @return BelongsToMany|\App\Models\User[]
*/ */
public function judges() public function judges(): array|BelongsToMany
{ {
return $this->belongsToMany( return $this->belongsToMany(
User::class, // The related model User::class, // The related model
@ -150,10 +152,10 @@ class Audition extends Model
*/ */
public function getJudgesCountAttribute() public function getJudgesCountAttribute()
{ {
if (!isset($this->attributes['judges_count'])) { if (! isset($this->attributes['judges_count'])) {
$this->attributes['judges_count'] = $this->judges()->count(); $this->attributes['judges_count'] = $this->judges()->count();
} }
return $this->attributes['judges_count']; return $this->attributes['judges_count'];
} }
} }

View File

@ -54,23 +54,23 @@ class AppServiceProvider extends ServiceProvider
return new SeatingService(); return new SeatingService();
}); });
$this->app->singleton(EntryCacheService::class, function($app) { $this->app->singleton(EntryCacheService::class, function ($app) {
return new EntryCacheService($app->make(AuditionCacheService::class)); return new EntryCacheService($app->make(AuditionCacheService::class));
}); });
$this->app->singleton(ScoreService::class, function($app) { $this->app->singleton(ScoreService::class, function ($app) {
return new ScoreService($app->make(AuditionCacheService::class), $app->make(EntryCacheService::class)); return new ScoreService($app->make(AuditionCacheService::class), $app->make(EntryCacheService::class));
}); });
$this->app->singleton(TabulationService::class, function($app) { $this->app->singleton(TabulationService::class, function ($app) {
return new TabulationService( return new TabulationService(
$app->make(AuditionCacheService::class), $app->make(AuditionCacheService::class),
$app->make(ScoreService::class), $app->make(ScoreService::class),
$app->make(EntryCacheService::class)); $app->make(EntryCacheService::class));
}); });
$this->app->singleton(DoublerService::class, function($app) { $this->app->singleton(DoublerService::class, function ($app) {
return new DoublerService($app->make(AuditionCacheService::class),$app->make(TabulationService::class),$app->make(SeatingService::class)); return new DoublerService($app->make(AuditionCacheService::class), $app->make(TabulationService::class), $app->make(SeatingService::class));
}); });
} }
@ -91,7 +91,6 @@ class AppServiceProvider extends ServiceProvider
SubscoreDefinition::observe(SubscoreDefinitionObserver::class); SubscoreDefinition::observe(SubscoreDefinitionObserver::class);
User::observe(UserObserver::class); User::observe(UserObserver::class);
Event::listen( Event::listen(
AuditionChange::class, AuditionChange::class,
RefreshAuditionCache::class RefreshAuditionCache::class

View File

@ -1,5 +1,7 @@
@inject('doublerService','App\Services\DoublerService') @inject('doublerService','App\Services\DoublerService')
@php($blockSeating = []) @php
$blockSeating = []
@endphp
<x-layout.app> <x-layout.app>
<x-slot:page_title>Audition Seating - {{ $audition->name }}</x-slot:page_title> <x-slot:page_title>Audition Seating - {{ $audition->name }}</x-slot:page_title>
<div class="grid grid-cols-4"></div> <div class="grid grid-cols-4"></div>
@ -8,20 +10,43 @@
@include('tabulation.audition-results-table') @include('tabulation.audition-results-table')
</div> </div>
<div class="ml-4"> <div class="ml-4">
<x-card.card> @if(! $auditionComplete)
<x-card.heading> <x-card.card>
Seating Form <x-card.heading>Unable to seat this audition</x-card.heading>
</x-card.heading> @if(! $scoringComplete)
<div class="pl-3"> <p class="text-sm px-5 py-2">The audition cannot be seated while it has unscored entries.</p>
@if(! $complete)
Unable to seat. Not all entries are scored.<br>
@endif @endif
@if(! $doublerComplete) @if(! $doublerComplete)
Unable to seat. Not all doublers are resolved.<br> <p class="text-sm px-5 py-2">The audition cannot be seated while it has unresolved doublers.</p>
@endif @endif
</div> </x-card.card>
</x-card.card> @endif
@if($auditionComplete)
@php
$entriesToSeat = $entries->reject(function ($entry) {
return $entry->hasFlag('declined');
});
@endphp
@foreach($ensembleLimits as $ensembleLimit)
<x-card.card class="mb-3">
<x-card.heading>{{ $ensembleLimit->ensemble->name }}</x-card.heading>
<x-card.list.body>
@for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++)
@php
$entry = $entriesToSeat->shift();
if (is_null($entry)) continue;
@endphp
<x-card.list.row class="!py-2">
{{ $n }} - {{ $entry->student->full_name() }}
</x-card.list.row>
@endfor
</x-card.list.body>
</x-card.card>
@endforeach
@endif
</div> </div>
</div> </div>