Add new judging categories

This commit is contained in:
Russ Long 2022-06-08 20:21:59 -04:00
parent fdfbf8dafa
commit 050952e1a9

View File

@ -134,38 +134,71 @@ class TabulateWinners extends Command
return $zeroTo432ndQuery->vehicle; return $zeroTo432ndQuery->vehicle;
} }
function fortyFourToCurrentWinner() function fortyFourToNinetySevenWinner()
{ {
$fortyFourToCurrentQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id') $fortyFourToNinetySevenQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id') ->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore') ->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){ ->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners'); $query->select('vehicle')->from('car_show_winners');
}) })
->where('vehicles.year', '>=', 1944) ->where('vehicles.year', '>=', 1944)
//->where('vehicles.year', '<=', 1959) ->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0) ->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc') ->orderBy('totalscore','desc')
->first(); ->first();
return $fortyFourToCurrentQuery->vehicle; return $fortyFourToNinetySevenQuery->vehicle;
} }
function fortyFourToCurrent2ndWinner() function fortyFourToNinetySeven2ndWinner()
{ {
$fortyFourToCurrent2ndQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id') $fortyFourToNinetySeven2ndQuery = VehicleScores::join('vehicles', 'vehicle_scores.vehicle', '=', 'vehicles.id')
->groupBy('vehicles.id') ->groupBy('vehicles.id')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore') ->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){ ->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners'); $query->select('vehicle')->from('car_show_winners');
}) })
->where('vehicles.year', '>=', 1944) ->where('vehicles.year', '>=', 1944)
//->where('vehicles.year', '<=', 1959) ->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0) ->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc') ->orderBy('totalscore','desc')
->first(); ->first();
return $fortyFourToCurrent2ndQuery->vehicle; return $fortyFourToNinetySeven2ndQuery->vehicle;
} }
function NinetyEightToCurrentWinner()
{
$NinetyEightToCurrentQuery = 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', '>=', 1998)
//->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $NinetyEightToCurrentQuery->vehicle;
}
function NinetyEightToCurrent2ndWinner()
{
$NinetyEightToCurrent2ndQuery = 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', '>=', 1998)
//->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->first();
return $NinetyEightToCurrent2ndQuery->vehicle;
}
//Insert Best In Show Winner //Insert Best In Show Winner
CarShowWinner::updateOrCreate( CarShowWinner::updateOrCreate(
[ [
@ -230,14 +263,14 @@ class TabulateWinners extends Command
'vehicle' => zeroTo432ndWinner() 'vehicle' => zeroTo432ndWinner()
] ]
); );
//1944-Current //1944-1997
CarShowWinner::updateOrCreate( CarShowWinner::updateOrCreate(
[ [
'category' => '18', 'category' => '18',
'place' => 'first' 'place' => 'first'
], ],
[ [
'vehicle' => fortyFourToCurrentWinner() 'vehicle' => fortyFourToNinetySevenWinner()
] ]
); );
@ -247,7 +280,28 @@ class TabulateWinners extends Command
'place' => 'second' 'place' => 'second'
], ],
[ [
'vehicle' => fortyFourToCurrent2ndWinner() 'vehicle' => fortyFourToNinetySeven2ndWinner()
]
);
//1998-Current
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'first'
],
[
'vehicle' => NinetyEightToCurrentWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'second'
],
[
'vehicle' => NinetyEightToCurrent2ndWinner()
] ]
); );
} }