Ranking: Changing degree of headings

This commit is contained in:
Torsten 2017-11-30 11:07:27 +01:00
parent faf00dc0cb
commit abf66ea3c9
5 changed files with 74 additions and 31 deletions

View file

@ -179,8 +179,8 @@ class League extends Model
// Für Auf/Abstiegsberechnung - wird auf previous Season angewendet.
// Unified bezieht sich (nur) auf Gruppen-Übergreifende Listung (also alle Untergruppen)
// Rank = -1 bedeutet über alle Rank (benötigt für Auf- und Abstieg über alle Ligen)
// getUnifiedRanking bezieht sich (nur) auf Gruppen-Übergreifende Listung (also alle Untergruppen)
// Rank = -1 bedeutet über alle Ranks (benötigt für Auf- und Abstieg über alle Ligen)
public static function getUnifiedRanking($rank, $seasonId=-1) {
$leagueScores = League::getRanking($rank, $seasonId);
$unifiedScores = array();
@ -214,7 +214,11 @@ class League extends Model
$tpl[5] = $rankEntry[4]; // league_pos (for multiple leagues per rank, usually ranks 3 and 4)
if ($rank==4) { $hasRank4=true;}
array_push($totalRanking, $tpl);
// only add to list if user has paid for season
if (User::is_season_paid($tpl[0])=="Ja") {
array_push($totalRanking, $tpl);
}
}
}
@ -296,9 +300,13 @@ class League extends Model
// TODO: 22 Mitspieler festgelegt sind.
public static function createLeagues($start_round_id, $round_count) {
Log::info("Leagues\League::createLeagues, start_round_id=".$start_round_id.", round_count=".$round_count);
$currentSeason=Season::getCurrent();
$previousSeason=Season::getPrevious();
$userNames = User::getNames();
// Eventuell vorhandene Ligen loeschen
$leagues=League::where('season_id','=',$currentSeason->id)->get();
if ($leagues) {
@ -362,6 +370,7 @@ class League extends Model
// - 2.) unified Liste bauen
// - 3.) Wenn Vorsaison keine Quali war, dann Auf & Abstieg umsetzen ( unfified Liste als Basis )
// - 4.) Member den Ligen zuordnen
Log::info("League::createLeagues => Previous season detected. Creating Leagues 1, 2 and 3");
// Erzeugung der Ligen
$createdLeagues=array();
@ -410,16 +419,37 @@ class League extends Model
}
}
Log::info("Creating unified List from previous season");
$unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !!
Log:info("Unified List:");
$userNames = User::getNames();
$unifiedList2=array(); // We will only transfer users over to here that have paid the current season and are not deleted.
$count=0;
foreach($unifiedList as $listEntry) {
$userId = $listEntry[0];
if (User::is_season_paid($userId) && !User::isDeleted($userId)) {
$count+=1;
array_push($unifiedList2, $listEntry);
Log::info($count.".) [".$userId."] ".$userNames[$userId]);
} else {
Log::info($count.".) [".$userId."] ".$userNames[$userId]." [DELETED]");
}
}
$unifiedList = $unifiedList2;
// Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind.
Log::info("Adding new users not within previous season");
foreach( League::getNewUsers() as $entry) {
array_push($unifiedList, $entry);
$userId=$entry[0];
Log::info("( [".$userId."] ".$userNames[$userId]." )");
}
$currentCount = 1;
$nr=1;
@ -449,7 +479,8 @@ class League extends Model
$leagueIndex+=1;
}
Log::info("#".$leagueCount." Liga ".$leagueNr."-".$subLeague.")".$nr." ".$entry[0]);
Log::info("#".$leagueCount." Liga ".$leagueNr."-".$subLeague.") ".$nr." ".$entry[0]." (".$userNames[$entry[0]].")");
$league=$createdLeagues[$leagueIndex];
$leagueMember = LeagueMember::create([
'user_id' => $entry[0],