Progress, but doubler block is inefficient
This commit is contained in:
parent
ef7cc131e0
commit
6ab624146c
|
|
@ -82,7 +82,9 @@ class TabulationController extends Controller
|
||||||
|
|
||||||
public function status()
|
public function status()
|
||||||
{
|
{
|
||||||
$auditions = Audition::with(['entries.scoreSheets','room.judges'])->orderBy('score_order')->get();
|
$auditions = Audition::with(['entries' => function($query) {
|
||||||
|
$query->withCount('scoreSheets');
|
||||||
|
},'room.judges'])->orderBy('score_order')->get();
|
||||||
|
|
||||||
return view('tabulation.status',compact('auditions'));
|
return view('tabulation.status',compact('auditions'));
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +95,7 @@ class TabulationController extends Controller
|
||||||
// $entries = $entries->sortByDesc(function ($entry) {
|
// $entries = $entries->sortByDesc(function ($entry) {
|
||||||
// return $entry->totalScore();
|
// return $entry->totalScore();
|
||||||
// });
|
// });
|
||||||
$entries = $audition->rankedEntries()->load('student.entries','scoreSheets.audition.scoringGuide.subscores');
|
$entries = $audition->rankedEntries()->load('student.entries.audition','scoreSheets.audition.scoringGuide.subscores');
|
||||||
$judges = $audition->judges();
|
$judges = $audition->judges();
|
||||||
return view('tabulation.auditionSeating',compact('audition','entries','judges'));
|
return view('tabulation.auditionSeating',compact('audition','entries','judges'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,21 @@ class Audition extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
protected $rankedEntries = null;
|
||||||
|
protected static $completeAuditions = null;
|
||||||
|
|
||||||
|
public static function getCompleteAuditions()
|
||||||
|
{
|
||||||
|
if (self::$completeAuditions) return self::$completeAuditions;
|
||||||
|
$auditions = Audition::with(['entries' => function($query) {
|
||||||
|
$query->withCount('scoreSheets');
|
||||||
|
},'room.judges'])->get();
|
||||||
|
self::$completeAuditions = $auditions->filter(function ($audition) {
|
||||||
|
return $audition->scoringIsComplete();
|
||||||
|
});
|
||||||
|
return self::$completeAuditions;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static function deadlineNotPast()
|
public static function deadlineNotPast()
|
||||||
{
|
{
|
||||||
|
|
@ -123,16 +138,6 @@ class Audition extends Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function judges()
|
|
||||||
// {
|
|
||||||
// // Very inefficient, need a better way
|
|
||||||
// return User::join('room_user', 'users.id', '=', 'room_user.user_id')
|
|
||||||
// ->join('rooms', 'room_user.room_id', '=', 'rooms.id')
|
|
||||||
// ->join('auditions', 'rooms.id', '=', 'auditions.room_id')
|
|
||||||
// ->where('auditions.id', $this->id)
|
|
||||||
// ->select('users.*') // avoid getting other tables' columns
|
|
||||||
// ->get();
|
|
||||||
// }
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
|
|
@ -144,27 +149,40 @@ class Audition extends Model
|
||||||
public function scoredEntries()
|
public function scoredEntries()
|
||||||
{
|
{
|
||||||
return $this->entries->filter(function($entry) {
|
return $this->entries->filter(function($entry) {
|
||||||
return $entry->scoreSheets->count() >= $this->judges()->count();
|
return $entry->score_sheets_count >= $this->judges()->count();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rankedEntries()
|
public function rankedEntries()
|
||||||
{
|
{
|
||||||
$entries = $this->entries()->with(['audition.scoringGuide.subscores','scoreSheets.judge'])->get();
|
if (! $this->rankedEntries) {
|
||||||
$entries = $entries->all();
|
$entries = $this->entries()->with(['audition.scoringGuide.subscores', 'scoreSheets.judge'])->get();
|
||||||
usort($entries, function($a,$b) {
|
$entries = $entries->all();
|
||||||
$aScores = $a->finalScoresArray();
|
usort($entries, function ($a, $b) {
|
||||||
$bScores = $b->finalScoresArray();
|
$aScores = $a->finalScoresArray();
|
||||||
|
$bScores = $b->finalScoresArray();
|
||||||
|
|
||||||
$length = min(count($aScores), count($bScores));
|
$length = min(count($aScores), count($bScores));
|
||||||
for ($i=0; $i<$length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
if ($aScores[$i] !== $bScores[$i]) {
|
if ($aScores[$i] !== $bScores[$i]) {
|
||||||
return $bScores[$i] - $aScores[$i];
|
return $bScores[$i] - $aScores[$i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
return 0;
|
});
|
||||||
});
|
$collection = new \Illuminate\Database\Eloquent\Collection($entries);
|
||||||
$collection = new \Illuminate\Database\Eloquent\Collection($entries);
|
$this->rankedEntries = $collection;
|
||||||
return $collection;
|
}
|
||||||
|
return $this->rankedEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scoringIsComplete()
|
||||||
|
{
|
||||||
|
if (self::$completeAuditions) {
|
||||||
|
// check and see if this audition is in the list of complete auditions
|
||||||
|
return self::$completeAuditions->contains('id', $this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->scoredEntries()->count() == $this->entries->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,16 @@ class Entry extends Model
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyScoreSheets()
|
public function getScoreSheetsCountAttribute()
|
||||||
|
{
|
||||||
|
if (!isset($this->attributes['score_sheets_count'])) {
|
||||||
|
$this->attributes['score_sheets_count'] = $this->scoreSheets()->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->attributes['score_sheets_count'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyScoreSheets()
|
||||||
{
|
{
|
||||||
if ($this->hasCheckedScoreSheets) return true;
|
if ($this->hasCheckedScoreSheets) return true;
|
||||||
$judges = $this->audition->room->judges;
|
$judges = $this->audition->room->judges;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
@php use App\Models\Audition; @endphp
|
||||||
|
@props(['student'])
|
||||||
|
{{--complete badge--}}
|
||||||
|
{{--<p class="mt-0.5 whitespace-nowrap rounded-md bg-green-50 px-1.5 py-0.5 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">Complete</p>--}}
|
||||||
|
{{--in progress badge--}}
|
||||||
|
{{--<p class="mt-0.5 whitespace-nowrap rounded-md bg-gray-50 px-1.5 py-0.5 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10">In progress</p>--}}
|
||||||
|
|
||||||
|
<ul role="list" class="divide-y divide-gray-100">
|
||||||
|
@foreach($student->entries as $entry)
|
||||||
|
<li class="flex items-center justify-between gap-x-1 py-5">
|
||||||
|
|
||||||
|
<div class="min-w-0">
|
||||||
|
|
||||||
|
<div class="flex items-start gap-x-3">
|
||||||
|
<p class="text-sm font-semibold leading-6 text-gray-900">
|
||||||
|
<a href="/tabulation/auditions/{{ $entry->audition->id }}">
|
||||||
|
{{ $entry->audition->name }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
@if(Audition::getCompleteAuditions()->contains('id', $entry->audition->id))
|
||||||
|
<p class="mt-0.5 whitespace-nowrap rounded-md bg-green-50 px-1.5 py-0.5 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">Complete</p>
|
||||||
|
@else
|
||||||
|
<p class="mt-0.5 whitespace-nowrap rounded-md bg-gray-50 px-1.5 py-0.5 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10">In progress</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-1 flex items-center gap-x-2 text-xs leading-5 text-gray-500">
|
||||||
|
@if(Audition::getCompleteAuditions()->contains('id', $entry->audition->id))
|
||||||
|
@php
|
||||||
|
$entryPlace = $entry->audition->rankedEntries()->search(function ($rankedEntry) use ($entry) {
|
||||||
|
return $rankedEntry->id == $entry->id;
|
||||||
|
});
|
||||||
|
@endphp
|
||||||
|
@if($entryPlace !== false)
|
||||||
|
Rank: {{ $entryPlace +1 }}{{-- The place of $entry->id in the array is $entryPlace --}}
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
@ -22,7 +22,11 @@
|
||||||
<x-table.td>{{ $entry->id }}</x-table.td>
|
<x-table.td>{{ $entry->id }}</x-table.td>
|
||||||
<x-table.td>{{ $entry->draw_number }}</x-table.td>
|
<x-table.td>{{ $entry->draw_number }}</x-table.td>
|
||||||
<x-table.td>{{ $entry->student->full_name(true) }}</x-table.td>
|
<x-table.td>{{ $entry->student->full_name(true) }}</x-table.td>
|
||||||
<x-table.td>{{ $entry->student->isDoubler() ? 'Doubler':'' }}</x-table.td>
|
<x-table.td>
|
||||||
|
@if($entry->student->isDoubler())
|
||||||
|
<x-doubler-block :student="$entry->student" />
|
||||||
|
@endif
|
||||||
|
</x-table.td>
|
||||||
{{-- @foreach($judges as $judge)--}}
|
{{-- @foreach($judges as $judge)--}}
|
||||||
{{-- <x-table.td>--}}
|
{{-- <x-table.td>--}}
|
||||||
{{-- @php--}}
|
{{-- @php--}}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
</a></x-table.td>
|
</a></x-table.td>
|
||||||
<x-table.td>{{ $audition->scoredEntries()->count() }} / {{ $audition->entries->count() }} Scored</x-table.td>
|
<x-table.td>{{ $audition->scoredEntries()->count() }} / {{ $audition->entries->count() }} Scored</x-table.td>
|
||||||
<td>
|
<td>
|
||||||
@if($audition->scoredEntries()->count() == $audition->entries->count())
|
@if($audition->scoringIsComplete())
|
||||||
<x-icons.checkmark color="green"/>
|
<x-icons.checkmark color="green"/>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,10 @@
|
||||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$audition = Audition::find(2);
|
$a = Audition::find(9);
|
||||||
$ranked = $audition->rankedEntries();
|
dump ($a->rankedEntries());
|
||||||
dump($ranked);
|
dump ($a->rankedEntries());
|
||||||
echo "<hr>plain entries<hr>";
|
dump ($a->rankedEntries());
|
||||||
dump($audition->entries());
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue