Add console command to force recalculation of judge totals
This commit is contained in:
parent
55d5dba840
commit
1c3bb39805
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Actions\Tabulation\EnterScore;
|
||||
use App\Models\ScoreSheet;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RecalculateJudgeTotalsCommand extends Command
|
||||
{
|
||||
protected $signature = 'audition:recalculate-judge-totals';
|
||||
|
||||
protected $description = 'Recalculates total scores for all score sheets for unpubished auditions';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Starting score recalculation...');
|
||||
$scoreSheets = ScoreSheet::all();
|
||||
foreach ($scoreSheets as $scoreSheet) {
|
||||
if ($scoreSheet->entry->audition->hasFlag('seats_published')) {
|
||||
continue;
|
||||
}
|
||||
$this->recalculate($scoreSheet);
|
||||
}
|
||||
|
||||
$this->info('Score recalculation completed successfully.');
|
||||
}
|
||||
|
||||
private function recalculate(ScoreSheet|int $scoreSheet): void
|
||||
{
|
||||
if (is_int($scoreSheet)) {
|
||||
$scoreSheet = ScoreSheet::findOrFail($scoreSheet);
|
||||
}
|
||||
$scribe = app()->make(EnterScore::class);
|
||||
$scoreSubmission = [];
|
||||
foreach ($scoreSheet->subscores as $subscore) {
|
||||
$scoreSubmission[$subscore['subscore_id']] = $subscore['score'];
|
||||
}
|
||||
$scribe($scoreSheet->judge, $scoreSheet->entry, $scoreSubmission, $scoreSheet);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,14 +8,14 @@ use Illuminate\Console\Command;
|
|||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class RecalculateScores extends Command
|
||||
class RecalculateTotalScores extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'audition:recalculate-scores';
|
||||
protected $signature = 'audition:recalculate-total-scores';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
Loading…
Reference in New Issue