Update scoring for 2022 show

This commit is contained in:
Russ Long 2022-05-01 08:58:49 -04:00
parent aa7909b4d5
commit cabf4a48d3
3 changed files with 474 additions and 258 deletions

View File

@ -46,9 +46,9 @@ class TabulateWinners extends Command
public function handle()
{
function mainWinner()
function bestInShowWinner()
{
$mainWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
$bestInShowWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
@ -57,8 +57,8 @@ class TabulateWinners extends Command
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $mainWinnerQuery->vehicle;
}
return $bestInShowWinnerQuery->vehicle;
}
function pcWinner()
{
@ -72,132 +72,40 @@ class TabulateWinners extends Command
->orderBy('totalscore','desc')
->first();
return $peoplesChoiceWinnerQuery->vehicle;
}
}
function oughtsTo49Winner()
function zeroTo43Winner()
{
$oughtsTo49Query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
$zeroTo43Query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1900)
->where('vehicles.year', '<=', 1949)
->where('vehicles.year', '>=', 0)
->where('vehicles.year', '<=', 1943)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $oughtsTo49Query->vehicle;
return $zeroTo43Query->vehicle;
}
function fiftiesWinner()
function fortyFourToCurrentWinner()
{
$fiftiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
$fortyFourToCurrentQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1950)
->where('vehicles.year', '<=', 1959)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $fiftiesQuery->vehicle;
}
function sixtiesWinner()
{
$sixtiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1960)
->where('vehicles.year', '<=', 1969)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $sixtiesQuery->vehicle;
}
function seventiesWinner()
{
$seventiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1970)
->where('vehicles.year', '<=', 1979)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $seventiesQuery->vehicle;
}
function eightiesWinner()
{
$eightiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1980)
->where('vehicles.year', '<=', 1989)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $eightiesQuery->vehicle;
}
function ninetiesWinner()
{
$ninetiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1990)
->where('vehicles.year', '<=', 1999)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $ninetiesQuery->vehicle;
}
function thousandsWinner()
{
$thousandsQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 2000)
->where('vehicles.year', '>=', 1944)
//->where('vehicles.year', '<=', 1959)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $thousandsQuery->vehicle;
}
function categoryWinner($category)
{
$categoryWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function ($query) {
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.doNotJudge', '=', 0)
->where('vehicles.type', '=', "$category")
->orderBy('totalscore', 'desc')
->first();
return $categoryWinnerQuery->vehicle;
return $fortyFourToCurrentQuery->vehicle;
}
//categories
/* Here for reference only
$individuallyProcessedAwards = array(
@ -205,30 +113,16 @@ class TabulateWinners extends Command
'pcFirst' => '3'
); */
$mainAwardsToCalculate = array(
// 'inShowFirst' =>'6',
// 'pcFirst' => '3',
'bestTruckFirst' => '5',
'corvetteFirst' => '7',
'camaroFirst' => '8',
// 'moparFirst' => '16',
'mustangFirst' => '1',
'ratRideFirst' => '4'
'inShowFirst' =>'6',
'inShowSecond' =>'6',
'pcFirst' => '3',
'pcSecond' => '3'
);
$yearAwardsToCalculate = array(
'oughtsTo49First' => '9',
'oughtsTo49Second' => '9',
'fiftiesFirst' => '10',
'fiftiesSecond' => '10',
'sixtiesFirst' => '11',
'sixtiesSecond' => '11',
'seventiesFirst' => '12',
'seventiesSecond' => '12',
'eightiesFirst' => '13',
'eightiesSecond' => '13',
'ninetiesFirst' => '14',
'ninetiesSecond' => '14',
'thousandsFirst' => '15',
'thousandsSecond' => '15'
'zeroTo43First' => '17',
'zeroTo43Second' => '17',
'fourtyFourToCurrentFirst' => '18',
'fourtyFourToCurrentSecond' => '18'
);
//Insert Best In Show Winner
CarShowWinner::updateOrCreate(
@ -237,174 +131,80 @@ class TabulateWinners extends Command
'place' => 'first'
],
[
'vehicle' => mainWinner()
'vehicle' => bestInShowWinner()
]
);
//Insert Best In Show 2nd Place Winner
CarShowWinner::updateOrCreate(
[
'category' => '6',
'place' => 'second'
],
[
'vehicle' => bestInShowWinner()
]
);
//Insert People's Choice Winner
/*CarShowWinner::updateOrCreate(
CarShowWinner::updateOrCreate(
[
'category' => '3',
'place' => 'first'
],
[
'vehicle' => $peoplesChoiceWinnerQuery
'vehicle' => pcWinner()
]
);*/
//Insert Category Award Winners
foreach($mainAwardsToCalculate as $mainaward => $category) {
$categorywinner = CarShowWinner::updateOrCreate(
[
'category' => $category,
'place' => 'first'
],
[
'vehicle' => categoryWinner($category)
]
);
}
);
CarShowWinner::updateOrCreate(
[
'category' => '3',
'place' => 'second'
],
[
'vehicle' => pcWinner()
]
);
//Insert Year Award Winners
//1900-1949
//0-1943
CarShowWinner::updateOrCreate(
[
'category' => '9',
'category' => '17',
'place' => 'first'
],
[
'vehicle' => oughtsTo49Winner()
'vehicle' => zeroTo43Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '9',
'category' => '17',
'place' => 'second'
],
[
'vehicle' => oughtsTo49Winner()
'vehicle' => zeroTo43Winner()
]
);
//1950-1959
//1944-Current
CarShowWinner::updateOrCreate(
[
'category' => '10',
'category' => '18',
'place' => 'first'
],
[
'vehicle' => fiftiesWinner()
'vehicle' => fortyFourToCurrentWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '10',
'category' => '18',
'place' => 'second'
],
[
'vehicle' => fiftiesWinner()
]
);
//1960-1969
CarShowWinner::updateOrCreate(
[
'category' => '11',
'place' => 'first'
],
[
'vehicle' => sixtiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '11',
'place' => 'second'
],
[
'vehicle' => sixtiesWinner()
]
);
//1970-1979
CarShowWinner::updateOrCreate(
[
'category' => '12',
'place' => 'first'
],
[
'vehicle' => seventiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '12',
'place' => 'second'
],
[
'vehicle' => seventiesWinner()
]
);
//1980-1989
CarShowWinner::updateOrCreate(
[
'category' => '13',
'place' => 'first'
],
[
'vehicle' => eightiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '13',
'place' => 'second'
],
[
'vehicle' => eightiesWinner()
]
);
//1990-1999
CarShowWinner::updateOrCreate(
[
'category' => '14',
'place' => 'first'
],
[
'vehicle' => ninetiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '14',
'place' => 'second'
],
[
'vehicle' => ninetiesWinner()
]
);
//2000-present
CarShowWinner::updateOrCreate(
[
'category' => '15',
'place' => 'first'
],
[
'vehicle' => thousandsWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '15',
'place' => 'second'
],
[
'vehicle' => thousandsWinner()
'vehicle' => fortyFourToCurrentWinner()
]
);
}

View File

@ -0,0 +1,411 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Bidders;
use App\Models\CarShowCategory;
use App\Models\CarShowWinner;
use App\Models\PeoplesChoice;
use App\Models\Vehicles;
use App\Models\VehicleScores;
use Illuminate\Support\Facades\DB;
class TabulateWinners extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'carshow:tabulatewinners';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Tabulate Show Winners, and add them to the CarShowWinner table';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
function mainWinner()
{
$mainWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $mainWinnerQuery->vehicle;
}
function pcWinner()
{
$peoplesChoiceWinnerQuery = DB::table('peoples_choice')
->groupBy('peoples_choice.vehicle')
->selectRaw('*, sum(pc_count as totalscore')
->whereNotIn('vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $peoplesChoiceWinnerQuery->vehicle;
}
function oughtsTo49Winner()
{
$oughtsTo49Query = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1900)
->where('vehicles.year', '<=', 1949)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $oughtsTo49Query->vehicle;
}
function fiftiesWinner()
{
$fiftiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1950)
->where('vehicles.year', '<=', 1959)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $fiftiesQuery->vehicle;
}
function sixtiesWinner()
{
$sixtiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1960)
->where('vehicles.year', '<=', 1969)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $sixtiesQuery->vehicle;
}
function seventiesWinner()
{
$seventiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1970)
->where('vehicles.year', '<=', 1979)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $seventiesQuery->vehicle;
}
function eightiesWinner()
{
$eightiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1980)
->where('vehicles.year', '<=', 1989)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $eightiesQuery->vehicle;
}
function ninetiesWinner()
{
$ninetiesQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1990)
->where('vehicles.year', '<=', 1999)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $ninetiesQuery->vehicle;
}
function thousandsWinner()
{
$thousandsQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 2000)
//->where('vehicles.year', '<=', 1959)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $thousandsQuery->vehicle;
}
function categoryWinner($category)
{
$categoryWinnerQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function ($query) {
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.doNotJudge', '=', 0)
->where('vehicles.type', '=', "$category")
->orderBy('totalscore', 'desc')
->first();
return $categoryWinnerQuery->vehicle;
}
//categories
/* Here for reference only
$individuallyProcessedAwards = array(
'inShowFirst' =>'6',
'pcFirst' => '3'
); */
$mainAwardsToCalculate = array(
// 'inShowFirst' =>'6',
// 'pcFirst' => '3',
'bestTruckFirst' => '5',
'corvetteFirst' => '7',
'camaroFirst' => '8',
// 'moparFirst' => '16',
'mustangFirst' => '1',
'ratRideFirst' => '4'
);
$yearAwardsToCalculate = array(
'oughtsTo49First' => '9',
'oughtsTo49Second' => '9',
'fiftiesFirst' => '10',
'fiftiesSecond' => '10',
'sixtiesFirst' => '11',
'sixtiesSecond' => '11',
'seventiesFirst' => '12',
'seventiesSecond' => '12',
'eightiesFirst' => '13',
'eightiesSecond' => '13',
'ninetiesFirst' => '14',
'ninetiesSecond' => '14',
'thousandsFirst' => '15',
'thousandsSecond' => '15'
);
//Insert Best In Show Winner
CarShowWinner::updateOrCreate(
[
'category' => '6',
'place' => 'first'
],
[
'vehicle' => mainWinner()
]
);
//Insert People's Choice Winner
/*CarShowWinner::updateOrCreate(
[
'category' => '3',
'place' => 'first'
],
[
'vehicle' => $peoplesChoiceWinnerQuery
]
);*/
//Insert Category Award Winners
foreach($mainAwardsToCalculate as $mainaward => $category) {
$categorywinner = CarShowWinner::updateOrCreate(
[
'category' => $category,
'place' => 'first'
],
[
'vehicle' => categoryWinner($category)
]
);
}
//Insert Year Award Winners
//1900-1949
CarShowWinner::updateOrCreate(
[
'category' => '9',
'place' => 'first'
],
[
'vehicle' => oughtsTo49Winner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '9',
'place' => 'second'
],
[
'vehicle' => oughtsTo49Winner()
]
);
//1950-1959
CarShowWinner::updateOrCreate(
[
'category' => '10',
'place' => 'first'
],
[
'vehicle' => fiftiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '10',
'place' => 'second'
],
[
'vehicle' => fiftiesWinner()
]
);
//1960-1969
CarShowWinner::updateOrCreate(
[
'category' => '11',
'place' => 'first'
],
[
'vehicle' => sixtiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '11',
'place' => 'second'
],
[
'vehicle' => sixtiesWinner()
]
);
//1970-1979
CarShowWinner::updateOrCreate(
[
'category' => '12',
'place' => 'first'
],
[
'vehicle' => seventiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '12',
'place' => 'second'
],
[
'vehicle' => seventiesWinner()
]
);
//1980-1989
CarShowWinner::updateOrCreate(
[
'category' => '13',
'place' => 'first'
],
[
'vehicle' => eightiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '13',
'place' => 'second'
],
[
'vehicle' => eightiesWinner()
]
);
//1990-1999
CarShowWinner::updateOrCreate(
[
'category' => '14',
'place' => 'first'
],
[
'vehicle' => ninetiesWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '14',
'place' => 'second'
],
[
'vehicle' => ninetiesWinner()
]
);
//2000-present
CarShowWinner::updateOrCreate(
[
'category' => '15',
'place' => 'first'
],
[
'vehicle' => thousandsWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '15',
'place' => 'second'
],
[
'vehicle' => thousandsWinner()
]
);
}
}

View File

@ -146,6 +146,11 @@
Car Show Winners
</a>
</li>
<li>
<a href="/showscores">
Vehicle Total Scores
</a>
</li>
</ul>
</li>
<li class="dropdown">