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;
}
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')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1944)
//->where('vehicles.year', '<=', 1959)
->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->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')
->selectRaw('*, sum(vehicle_scores.overall_score) as totalscore')
->whereNotIn('vehicle_scores.vehicle', function($query){
$query->select('vehicle')->from('car_show_winners');
})
->where('vehicles.year', '>=', 1944)
//->where('vehicles.year', '<=', 1959)
->where('vehicles.year', '<=', 1997)
->where('vehicles.doNotJudge', '=', 0)
->orderBy('totalscore','desc')
->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
CarShowWinner::updateOrCreate(
[
@ -230,14 +263,14 @@ class TabulateWinners extends Command
'vehicle' => zeroTo432ndWinner()
]
);
//1944-Current
//1944-1997
CarShowWinner::updateOrCreate(
[
'category' => '18',
'place' => 'first'
],
[
'vehicle' => fortyFourToCurrentWinner()
'vehicle' => fortyFourToNinetySevenWinner()
]
);
@ -247,8 +280,29 @@ class TabulateWinners extends Command
'place' => 'second'
],
[
'vehicle' => fortyFourToCurrent2ndWinner()
'vehicle' => fortyFourToNinetySeven2ndWinner()
]
);
//1998-Current
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'first'
],
[
'vehicle' => NinetyEightToCurrentWinner()
]
);
CarShowWinner::updateOrCreate(
[
'category' => '19',
'place' => 'second'
],
[
'vehicle' => NinetyEightToCurrent2ndWinner()
]
);
}
}