Fixed new player bug
This commit is contained in:
parent
622ecaf97c
commit
25cd90a1fb
5 changed files with 93 additions and 17 deletions
|
|
@ -268,6 +268,28 @@ class League extends Model
|
|||
}
|
||||
|
||||
|
||||
public static function getNewUsers($seasonId=-1) {
|
||||
$users=User::getActives($seasonId);
|
||||
$previousSeason=Season::getPrevious($seasonId);
|
||||
$old_users=User::getActives($previousSeason->id);
|
||||
|
||||
$new_users=array();
|
||||
foreach($users as $user) {
|
||||
$exists=0;
|
||||
foreach($old_users as $old_user) {
|
||||
if ($old_user->id == $user->id) { $exists=1;}
|
||||
}
|
||||
if (!$exists) {
|
||||
if (User::payment_date($user->id, $seasonId)) {
|
||||
$entry = [$user->id];
|
||||
array_push($new_users, $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $new_users;
|
||||
}
|
||||
|
||||
// ausfaktoriert aus LeaguesController::createLeagues()
|
||||
// TODO: $round_count ist nur im Quali-Modus relevant und steuert, wieviele Quali-Gruppen benötigt werden.
|
||||
// TODO: Sobald es Liga1 und Liga2 gibt, wird der round_count immer 21 sein, da Liga1 und Liga2 auf
|
||||
|
|
@ -329,6 +351,7 @@ class League extends Model
|
|||
'league_id' => $league_ids[$league_index]
|
||||
]);
|
||||
$leagueMember->save();
|
||||
error_log("Saving user_id ".$user->id);
|
||||
$league_index+=1;
|
||||
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
||||
}
|
||||
|
|
@ -388,6 +411,15 @@ class League extends Model
|
|||
}
|
||||
|
||||
$unifiedList = League::getTotalRankingOverall($previousSeason->id); // WICHTIG !! getTotalRankingOverall implentiert Auf- und Abstieg !!
|
||||
|
||||
// Jetzt neue Spieler hinzufügen, die letzte Saison noch nicht dabei waren, und deshalb in getTotalRankingOverall nicht enthalten sind.
|
||||
|
||||
foreach( League::getNewUsers() as $entry) {
|
||||
array_push($unifiedList, $entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$currentCount = 1;
|
||||
|
||||
$nr=1;
|
||||
|
|
@ -404,6 +436,11 @@ class League extends Model
|
|||
if ($nr==45) {
|
||||
$leagueNr=3; $leagueCount=1; $leagueIndex=2;
|
||||
$neededSize3=intdiv(($active_member_count-44),$neededLeagues); // $neededLeagues = needed Groups for rank 3 leagues
|
||||
|
||||
if ( ($active_member_count-44) % 2) {
|
||||
$neededSize3+=1;
|
||||
}
|
||||
|
||||
Log::info("Needed min/switch size for rank 3 leagues: ".$neededSize3);
|
||||
}
|
||||
if ($nr>45 && $leagueCount > $neededSize3) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue