Count noshows as a scored entry on audition status list.
This commit is contained in:
parent
fb9efa0564
commit
93d4305131
|
|
@ -14,22 +14,29 @@ class SeatingStatusController extends Controller
|
||||||
public function __invoke(Request $request)
|
public function __invoke(Request $request)
|
||||||
{
|
{
|
||||||
$auditions = Audition::forSeating()
|
$auditions = Audition::forSeating()
|
||||||
->withCount(['entries'=> function ($query) {
|
->withCount([
|
||||||
$query->where('for_seating', 1);
|
'entries' => function ($query) {
|
||||||
}])
|
$query->where('for_seating', 1);
|
||||||
->withCount(['unscoredEntries'=>function ($query) {
|
},
|
||||||
$query->where('for_seating', 1);
|
])
|
||||||
}])
|
->withCount([
|
||||||
|
'unscoredEntries' => function ($query) {
|
||||||
|
$query->where('for_seating', 1);
|
||||||
|
},
|
||||||
|
])
|
||||||
->with('flags')
|
->with('flags')
|
||||||
->get();
|
->get();
|
||||||
$auditionData = [];
|
$auditionData = [];
|
||||||
foreach ($auditions as $audition) {
|
foreach ($auditions as $audition) {
|
||||||
|
$noShowCount = $audition->entries->filter(function ($entry) {
|
||||||
|
return $entry->hasFlag('no_show');
|
||||||
|
})->count();
|
||||||
$auditionData[$audition->id] = [
|
$auditionData[$audition->id] = [
|
||||||
'id' => $audition->id,
|
'id' => $audition->id,
|
||||||
'name' => $audition->name,
|
'name' => $audition->name,
|
||||||
'scoredEntriesCount' => $audition->entries_count - $audition->unscored_entries_count,
|
'scoredEntriesCount' => $audition->entries_count - $audition->unscored_entries_count + $noShowCount,
|
||||||
'totalEntriesCount' => $audition->entries_count,
|
'totalEntriesCount' => $audition->entries_count,
|
||||||
'scoredPercentage' => $audition->entries_count > 0 ? ($audition->entries_count - $audition->unscored_entries_count) / $audition->entries_count * 100 : 100,
|
'scoredPercentage' => $audition->entries_count > 0 ? ($audition->entries_count - $audition->unscored_entries_count + $noShowCount) / $audition->entries_count * 100 : 100,
|
||||||
'scoringComplete' => $audition->unscored_entries_count === 0,
|
'scoringComplete' => $audition->unscored_entries_count === 0,
|
||||||
'seatsPublished' => $audition->hasFlag('seats_published'),
|
'seatsPublished' => $audition->hasFlag('seats_published'),
|
||||||
'audition' => $audition,
|
'audition' => $audition,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue