Eliminate custom excpetion
This commit is contained in:
parent
03953452b2
commit
01c0365b5d
|
|
@ -16,9 +16,7 @@ class TabulationException extends Exception
|
||||||
|
|
||||||
public function render($request)
|
public function render($request)
|
||||||
{
|
{
|
||||||
// if ($e instanceof TabulationException) {
|
dd('in the render');
|
||||||
return redirect('/tabulation/status')->with('error', $this->getMessage());
|
return redirect('/tabulation/status')->with('error', $this->getMessage());
|
||||||
// }
|
|
||||||
// return parent::render($request, $e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use App\Services\AuditionCacheService;
|
use App\Services\AuditionCacheService;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
|
||||||
class TabulationService
|
class TabulationService
|
||||||
|
|
@ -63,7 +64,7 @@ class TabulationService
|
||||||
*/
|
*/
|
||||||
public function entryFinalScores(Entry $entry) {
|
public function entryFinalScores(Entry $entry) {
|
||||||
$audition = $this->auditionCacheService->getAudition($entry->audition_id);
|
$audition = $this->auditionCacheService->getAudition($entry->audition_id);
|
||||||
$this->validateEntryScoreSheets($entry);
|
if (! $this->entryScoreSheetsAreValid($entry)) return null;
|
||||||
|
|
||||||
$subscores = $audition->scoringGuide->subscores->sortBy('tiebreak_order');
|
$subscores = $audition->scoringGuide->subscores->sortBy('tiebreak_order');
|
||||||
$finalScoresArray = [];
|
$finalScoresArray = [];
|
||||||
|
|
@ -90,15 +91,14 @@ class TabulationService
|
||||||
return $finalScoresArray;
|
return $finalScoresArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function entryScoreSheetsAreValid(Entry $entry): bool {
|
||||||
* @throws TabulationException
|
//TODO consider making this move the invalid score to another database for further investication
|
||||||
*/
|
$validJudges = $this->auditionCacheService->getAudition($entry->audition_id)->judges;
|
||||||
public function validateEntryScoreSheets(Entry $entry): bool {
|
|
||||||
$audition = $this->auditionCacheService->getAudition($entry->audition_id);
|
|
||||||
foreach ($entry->scoreSheets as $sheet) {
|
foreach ($entry->scoreSheets as $sheet) {
|
||||||
if (! $audition->judges->contains($sheet->user_id)) {
|
if (! $validJudges->contains($sheet->user_id)) {
|
||||||
$invalidJudge = User::find($sheet->user_id);
|
$invalidJudge = User::find($sheet->user_id);
|
||||||
throw new TabulationException('Invalid scores for entry ' . $entry->id . ' exist from ' . $invalidJudge->full_name());
|
Session::flash('error','Invalid scores for entry ' . $entry->id . ' exist from ' . $invalidJudge->full_name());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Exceptions\TabulationException;
|
||||||
use App\Http\Middleware\LoadAuditionSettings;
|
use App\Http\Middleware\LoadAuditionSettings;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,16 @@
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
@endphp
|
@endphp
|
||||||
|
@inject('tabservice','App\Services\TabulationService');
|
||||||
<x-layout.app>
|
<x-layout.app>
|
||||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||||
|
|
||||||
@php(dd($auditions))
|
@php(dd($tabservice->entryScoreSheetsAreValid(Entry::find(1102))))
|
||||||
|
|
||||||
@foreach($auditions as $audition)
|
@foreach($auditions as $audition)
|
||||||
{{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entries_count }} are fully scored.<br>
|
{{ $audition->name }} has {{ $audition->entries_count }} entries. {{ $audition->scored_entries_count }} are
|
||||||
|
fully scored.<br>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</x-layout.app>
|
</x-layout.app>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue