Fix error in SeatAuditionFormController that resulted in all unresolved doublers being declined when doing mass declines.
This commit is contained in:
parent
f9fd6b1150
commit
115bd9b320
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers\Tabulation;
|
||||
|
||||
use App\Actions\Entries\DoublerDecision;
|
||||
use App\Actions\Tabulation\RankAuditionEntries;
|
||||
use App\Exceptions\AuditionAdminException;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
|
@ -19,7 +20,7 @@ use function redirect;
|
|||
|
||||
class SeatAuditionFormController extends Controller
|
||||
{
|
||||
public function showForm(Request $request, Audition $audition)
|
||||
public function showForm(Audition $audition)
|
||||
{
|
||||
$seatingProposal = (session('proposedSeatingArray-'.$audition->id));
|
||||
if ($audition->hasFlag('seats_published')) {
|
||||
|
|
@ -36,7 +37,13 @@ class SeatAuditionFormController extends Controller
|
|||
|
||||
$ranker = app(RankAuditionEntries::class);
|
||||
// Get scored entries in order
|
||||
$scored_entries = $ranker($audition, 'seating');
|
||||
try {
|
||||
$scored_entries = $ranker($audition, 'seating');
|
||||
} catch (AuditionAdminException $e) {
|
||||
return redirect()->route('seating.audition', ['audition' => $audition->id])
|
||||
->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
$scored_entries->load(['student.doublers', 'student.school']);
|
||||
// Get unscored entries sorted by draw number
|
||||
$unscored_entries = $audition->entries()
|
||||
|
|
@ -49,7 +56,7 @@ class SeatAuditionFormController extends Controller
|
|||
})
|
||||
->with('student.school')
|
||||
->withCount('scoreSheets')
|
||||
->orderBy('draw_number', 'asc')
|
||||
->orderBy('draw_number')
|
||||
->get();
|
||||
|
||||
// Get no show entries sorted by draw number
|
||||
|
|
@ -59,7 +66,7 @@ class SeatAuditionFormController extends Controller
|
|||
$query->where('flag_name', 'no_show');
|
||||
})
|
||||
->with('student.school')
|
||||
->orderBy('draw_number', 'asc')
|
||||
->orderBy('draw_number')
|
||||
->get();
|
||||
|
||||
// Get failed prelim entries sorted by draw number
|
||||
|
|
@ -69,7 +76,7 @@ class SeatAuditionFormController extends Controller
|
|||
$query->where('flag_name', 'failed_prelim');
|
||||
})
|
||||
->with('student.school')
|
||||
->orderBy('draw_number', 'asc')
|
||||
->orderBy('draw_number')
|
||||
->get();
|
||||
|
||||
// Get Doublers
|
||||
|
|
@ -110,8 +117,13 @@ class SeatAuditionFormController extends Controller
|
|||
|
||||
public function declineSeat(Audition $audition, Entry $entry)
|
||||
{
|
||||
$entry->addFlag('declined');
|
||||
Cache::forget('rank_seating_'.$entry->audition_id);
|
||||
$decider = app(DoublerDecision::class);
|
||||
try {
|
||||
$decider->decline($entry);
|
||||
} catch (AuditionAdminException $e) {
|
||||
return redirect()->route('seating.audition', ['audition' => $audition->id])
|
||||
->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('seating.audition', ['audition' => $audition->id])->with('success',
|
||||
$entry->student->full_name().' has declined '.$audition->name);
|
||||
|
|
@ -128,6 +140,11 @@ class SeatAuditionFormController extends Controller
|
|||
$scored_entries->load(['student.doublers', 'student.school']);
|
||||
foreach ($scored_entries as $entry) {
|
||||
Debugbar::info('Starting entry '.$entry->student->full_name());
|
||||
if ($entry->seatingRank < $validData['decline-below']) {
|
||||
Debugbar::info('Skipping '.$entry->student->full_name().' because they are ranked above decline threshold');
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($entry->hasFlag('declined')) {
|
||||
Debugbar::info('Skipping '.$entry->student->full_name().' because they have already been declined');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue