update, working on inter-season logic
This commit is contained in:
parent
66671b1e81
commit
beaba1d389
11 changed files with 45 additions and 1337 deletions
|
|
@ -75,14 +75,14 @@ class LeaguesController extends Controller
|
|||
return redirect("/seasons");
|
||||
}
|
||||
|
||||
public function showLeagueRounds($league_rank) {
|
||||
public function showLeagueRounds() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$season=Season::getCurrent();
|
||||
|
||||
$roundNames = Round::getNames();
|
||||
$leagueNames = League::getNames();
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','=', $league_rank)->orderBy('id')->get();
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<', 4)->orderBy('id')->get();
|
||||
$matchesTotal = array();
|
||||
|
||||
foreach ($leagues as $league) {
|
||||
|
|
@ -110,6 +110,7 @@ class LeaguesController extends Controller
|
|||
$userNames = User::getNames();
|
||||
|
||||
$leagueScores = League::getRanking($rank);
|
||||
|
||||
return view ('leagues.chart',compact('season','leagues', 'leagueNames', 'userNames','leagueScores'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ class UsersController extends Controller
|
|||
public function ranking($max_round_id, $seasonId=-1) {
|
||||
if (!Auth::user()) { return redirect("/"); }
|
||||
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$season = Season::getCurrent();
|
||||
|
|
@ -220,7 +219,6 @@ class UsersController extends Controller
|
|||
$max_round_id=min($max_round_id, Round::getLastLockedRoundId());
|
||||
|
||||
|
||||
|
||||
// Payment made ?
|
||||
if (! User::payment_date(Auth::user()->id, $season->id) && Auth::user()->name!="Torsten Schneider") {
|
||||
return view('users.no_payment');
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class Tipp extends Model
|
|||
$currentSeason = Season::getCurrent();
|
||||
if ($seasonId!=-1) { $currentSeason=Season::where('id','=',$seasonId)->first(); };
|
||||
|
||||
error_log("SeasonId=".$currentSeason->id);
|
||||
|
||||
|
||||
// Hier werden _alle_ Tipps der aktuellen Saison ausgerechnet, die $round_id Begrenzung wird erst später ausgewertet.
|
||||
// TODO: Nur die Runden durchrechnen, die aktuell sind, oder round_incomplete, alle anderen Runden (bis zur ersten unvollständigen) sollen in eine Cachetabelle gespeichert werden.
|
||||
|
|
|
|||
|
|
@ -105,8 +105,6 @@ class League extends Model
|
|||
if ($seasonId > -1) { $season=Season::where('id','=',$seasonId)->first(); };
|
||||
$leagues = League::where('rank','=',$rank)->where('season_id','=', $season->id)->orderBy('id')->get();
|
||||
|
||||
error_log("LeagueCount:".sizeof($leagues));
|
||||
|
||||
$leagueScores=array();
|
||||
foreach($leagues as $league) {
|
||||
$memberIds = LeagueMember::getMembers($league->id);
|
||||
|
|
@ -160,7 +158,7 @@ class League extends Model
|
|||
// Nur für Auf und Abstieg
|
||||
public static function getTotalRankingOverall($seasonId=-1) {
|
||||
$totalRanking=array();
|
||||
|
||||
$hasRank4 = false;
|
||||
foreach([1,2,3,4] as $rank) {
|
||||
|
||||
foreach (League::getUnifiedRanking($rank, $seasonId) as $rankEntry) {
|
||||
|
|
@ -171,10 +169,46 @@ class League extends Model
|
|||
$tpl[2] = $rankEntry[2];
|
||||
$tpl[3] = $rankEntry[3];
|
||||
$tpl[4] = $rank;
|
||||
if ($rank==4) { $hasRank4=true;}
|
||||
array_push($totalRanking, $tpl);
|
||||
}
|
||||
}
|
||||
|
||||
usort($totalRanking, array('App\Leagues\League','cmpScore'));
|
||||
|
||||
// kein Rank4 ==> Ligaspiel ==> Auf & Abstieg wird angewendet.
|
||||
if (!$hasRank4) {
|
||||
// Liga 1/2: Swap rank 17-22 <> 23-28 ==> index 16-21 to rank=2, index 22-27 to rank=1
|
||||
// Liga 2/3: Swap rank 39-44 <> 45-50 ==> index 38-43 to rank=3, index 44-49 to rank=2
|
||||
$totalRanking[16][4]=2;
|
||||
$totalRanking[17][4]=2;
|
||||
$totalRanking[18][4]=2;
|
||||
$totalRanking[19][4]=2;
|
||||
$totalRanking[20][4]=2;
|
||||
$totalRanking[21][4]=2;
|
||||
$totalRanking[22][4]=1;
|
||||
$totalRanking[23][4]=1;
|
||||
$totalRanking[24][4]=1;
|
||||
$totalRanking[25][4]=1;
|
||||
$totalRanking[26][4]=1;
|
||||
$totalRanking[27][4]=1;
|
||||
|
||||
$totalRanking[38][4]=3;
|
||||
$totalRanking[39][4]=3;
|
||||
$totalRanking[40][4]=3;
|
||||
$totalRanking[41][4]=3;
|
||||
$totalRanking[42][4]=3;
|
||||
$totalRanking[43][4]=3;
|
||||
$totalRanking[44][4]=2;
|
||||
$totalRanking[45][4]=2;
|
||||
$totalRanking[46][4]=2;
|
||||
$totalRanking[47][4]=2;
|
||||
$totalRanking[48][4]=2;
|
||||
$totalRanking[49][4]=2;
|
||||
|
||||
usort($totalRanking, array('App\Leagues\League','cmpScore'));
|
||||
}
|
||||
|
||||
return $totalRanking;
|
||||
|
||||
}
|
||||
|
|
@ -299,17 +333,8 @@ class League extends Model
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: LeagueMembers zu den Leagues hinzufügen, abhängig vom zuzuordnenden Platz
|
||||
|
||||
$unifiedList = League::getTotalRankingOverall($previousSeason->id);
|
||||
$unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !!
|
||||
$currentCount = 1;
|
||||
//TODO: Auf- und Abstieg
|
||||
|
||||
Log::info("-- CREATED LEAGUES --");
|
||||
foreach($createdLeagues as $createdLeague) {
|
||||
Log::info("-> ".$createdLeague->id.") ".$createdLeague->name);
|
||||
//TODO: Member erzeugen / zuordnen
|
||||
}
|
||||
|
||||
$nr=1;
|
||||
$leagueNr=1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue