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\Models\Audition;
use App\Services\DoublerService;
use App\Services\SeatingService;
use App\Services\TabulationService;
use function compact;
@ -12,13 +13,14 @@ use function compact;
class TabulationController extends Controller
{
protected $tabulationService;
protected $doublerService;
protected $seatingService;
public function __construct(TabulationService $tabulationService, DoublerService $doublerService)
public function __construct(TabulationService $tabulationService, DoublerService $doublerService, SeatingService $seatingService)
{
$this->tabulationService = $tabulationService;
$this->doublerService = $doublerService;
$this->seatingService = $seatingService;
}
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;
});
$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;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
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;
class Audition extends Model
{
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()
{
@ -38,7 +39,6 @@ class Audition extends Model
return $this->hasMany(Entry::class);
}
public function room(): BelongsTo
{
return $this->belongsTo(Room::class);
@ -49,9 +49,9 @@ class Audition extends Model
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
@ -82,7 +82,7 @@ class Audition extends Model
}
if ($this->relationLoaded('entries')) {
return $this->entries->every(function ($entry) {
return !is_null($entry->draw_number);
return ! is_null($entry->draw_number);
});
} else {
return $this->entries()->whereNull('draw_number')->doesntExist();
@ -107,13 +107,14 @@ class Audition extends Model
});
$hasNotNull = $this->entries->contains(function ($entry) {
return !is_null($entry->draw_number);
return ! is_null($entry->draw_number);
});
return $hasNull && $hasNotNull;
} else {
$hasNull = $this->entries()->whereNull('draw_number')->exists();
$hasNotNull = $this->entries()->whereNotNull('draw_number')->exists();
return $hasNull && $hasNotNull;
}
}
@ -126,6 +127,7 @@ class Audition extends Model
$entry->update(['draw_number' => $index + 1]);
$entry->save();
}
return null;
// TODO move all draw functions to a DrawService
}
@ -133,7 +135,7 @@ class Audition extends Model
/**
* @return BelongsToMany|\App\Models\User[]
*/
public function judges()
public function judges(): array|BelongsToMany
{
return $this->belongsToMany(
User::class, // The related model
@ -150,10 +152,10 @@ class Audition extends Model
*/
public function getJudgesCountAttribute()
{
if (!isset($this->attributes['judges_count'])) {
if (! isset($this->attributes['judges_count'])) {
$this->attributes['judges_count'] = $this->judges()->count();
}
return $this->attributes['judges_count'];
}
}

View File

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

View File

@ -1,5 +1,7 @@
@inject('doublerService','App\Services\DoublerService')
@php($blockSeating = [])
@php
$blockSeating = []
@endphp
<x-layout.app>
<x-slot:page_title>Audition Seating - {{ $audition->name }}</x-slot:page_title>
<div class="grid grid-cols-4"></div>
@ -8,20 +10,43 @@
@include('tabulation.audition-results-table')
</div>
<div class="ml-4">
@if(! $auditionComplete)
<x-card.card>
<x-card.heading>
Seating Form
</x-card.heading>
<div class="pl-3">
@if(! $complete)
Unable to seat. Not all entries are scored.<br>
<x-card.heading>Unable to seat this audition</x-card.heading>
@if(! $scoringComplete)
<p class="text-sm px-5 py-2">The audition cannot be seated while it has unscored entries.</p>
@endif
@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
</div>
</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>