diff --git a/app/Http/Controllers/Tabulation/SeatingStatusController.php b/app/Http/Controllers/Tabulation/SeatingStatusController.php index 037c87e..19f5a0c 100644 --- a/app/Http/Controllers/Tabulation/SeatingStatusController.php +++ b/app/Http/Controllers/Tabulation/SeatingStatusController.php @@ -34,9 +34,9 @@ class SeatingStatusController extends Controller $auditionData[$audition->id] = [ 'id' => $audition->id, 'name' => $audition->name, - 'scoredEntriesCount' => $audition->entries_count - $audition->unscored_entries_count + $noShowCount, + 'scoredEntriesCount' => $audition->entries_count - $audition->unscored_entries_count, 'totalEntriesCount' => $audition->entries_count, - 'scoredPercentage' => $audition->entries_count > 0 ? ($audition->entries_count - $audition->unscored_entries_count + $noShowCount) / $audition->entries_count * 100 : 100, + 'scoredPercentage' => $audition->entries_count > 0 ? ($audition->entries_count - $audition->unscored_entries_count) / $audition->entries_count * 100 : 100, 'scoringComplete' => $audition->unscored_entries_count === 0, 'seatsPublished' => $audition->hasFlag('seats_published'), 'audition' => $audition, diff --git a/app/Models/Audition.php b/app/Models/Audition.php index 0d160a9..ecf32f9 100644 --- a/app/Models/Audition.php +++ b/app/Models/Audition.php @@ -35,7 +35,10 @@ class Audition extends Model public function unscoredEntries(): HasMany { return $this->hasMany(Entry::class) - ->whereDoesntHave('scoreSheets'); + ->whereDoesntHave('scoreSheets') + ->whereDoesntHave('flags', function ($query) { + $query->where('flag_name', 'no_show'); + }); } public function room(): BelongsTo diff --git a/app/Services/DoublerService.php b/app/Services/DoublerService.php index 24efd99..403c013 100644 --- a/app/Services/DoublerService.php +++ b/app/Services/DoublerService.php @@ -40,7 +40,18 @@ class DoublerService protected function findDoublersForEvent(Event $event, string $mode = 'seating'): array { $this->validateEvent($event); - $entries = $event->entries()->with('audition')->with('student')->get(); + $entries = $event->entries() + ->with([ + 'audition' => function ($query) { + $query->withCount([ + 'unscoredEntries' => function ($query) { + $query->where('for_seating', 1); + }, + ]); + }, + ]) + ->with('student') + ->get(); $entries = match ($mode) { 'seating' => $entries->filter(fn ($entry) => $entry->for_seating === 1), 'advancement' => $entries->filter(fn ($entry) => $entry->for_advance === 1),