getAuditionsWithStatus functin of TaultionService working
This commit is contained in:
parent
44cde39c16
commit
b970828b31
|
|
@ -31,28 +31,31 @@ class TabulationService
|
|||
|
||||
public function getAuditionsWithStatus()
|
||||
{
|
||||
// Create an array with the number of scores for each entry
|
||||
$scoreCountByEntry = DB::table('score_sheets')
|
||||
->select('entry_id', DB::raw('count(*) as count'))
|
||||
->groupBy('entry_id')
|
||||
->get()
|
||||
->pluck('count','entry_id');
|
||||
|
||||
// Retrieve auditions from the cache and load entry IDs
|
||||
$auditions = $this->auditionCacheService->getAuditions();
|
||||
$auditions->load(['entries' => function ($query) {
|
||||
$query->select('id');
|
||||
}]);
|
||||
$auditions->load('entries');
|
||||
|
||||
$auditions->loadCount('judges');
|
||||
$auditions->loadCount('entries');
|
||||
|
||||
foreach ($auditions as $audition)
|
||||
{
|
||||
// Get the count of entries that have been scored
|
||||
$audition->scored_entries = $audition->entries->filter(function ($entry) use ($scoreCountByEntry) {
|
||||
return $entry->score_sheets_count == $scoreCountByEntry[$entry->id];
|
||||
});
|
||||
// WHY WILL THIS NOT WORK?????
|
||||
|
||||
foreach ($auditions as $audition) {
|
||||
$audition->scored_entries_count = 0;
|
||||
foreach ($audition->entries as $entry) {
|
||||
if ($audition->judges_count == $scoreCountByEntry[$entry->id]) {
|
||||
$entry->fully_scored = true;
|
||||
$audition->scored_entries_count++;
|
||||
} else {
|
||||
$entry->fully_scored = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $auditions;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
@foreach($auditions as $audition)
|
||||
@php
|
||||
dd($audition->scored_entries);
|
||||
@endphp
|
||||
{{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entry_count }} are fully scored.<br>
|
||||
{{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entries_count }} are fully scored.<br>
|
||||
@endforeach
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue