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