league fix for League3 consisting of a single group
This commit is contained in:
parent
0eea680e51
commit
0eda6f46c2
4 changed files with 24 additions and 19 deletions
|
|
@ -73,6 +73,7 @@ class LeaguesController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createLeagues($start_round_id, $round_count) {
|
public function createLeagues($start_round_id, $round_count) {
|
||||||
|
Log::info("CREATE_LEAGUES");
|
||||||
$a=new TimeLogger("LeaguesController::createLeagues()");
|
$a=new TimeLogger("LeaguesController::createLeagues()");
|
||||||
Log::info($a->getStartMessage());
|
Log::info($a->getStartMessage());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ class League extends Model
|
||||||
//
|
//
|
||||||
public static function neededLeagues($member_count, $round_count) {
|
public static function neededLeagues($member_count, $round_count) {
|
||||||
$max_members_per_league=22;
|
$max_members_per_league=22;
|
||||||
if ( $round_count < $max_members_per_league-1 ) { $max_members_per_league = $round_count+1; }
|
if ($member_count<=$max_members_per_league) return 1;
|
||||||
if ($member_count <= $max_members_per_league) return $member_count;
|
|
||||||
|
|
||||||
$neededLeagues = intdiv($member_count, $max_members_per_league);
|
$neededLeagues = intdiv($member_count, $max_members_per_league);
|
||||||
|
|
||||||
|
|
@ -163,17 +162,17 @@ class League extends Model
|
||||||
|
|
||||||
|
|
||||||
$lastLockedRoundId=Round::getLastLockedRoundId();
|
$lastLockedRoundId=Round::getLastLockedRoundId();
|
||||||
Log::info("LASTLOCKKEDROUNDID=".$lastLockedRoundId);
|
//Log::info("LASTLOCKKEDROUNDID=".$lastLockedRoundId);
|
||||||
$matches=Match::getMatchResults($league->id,-1);
|
$matches=Match::getMatchResults($league->id,-1);
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
if (Round::isCompleted($match->round_id) || $match->round_id==$lastLockedRoundId ) {
|
if (Round::isCompleted($match->round_id) || $match->round_id==$lastLockedRoundId ) {
|
||||||
$memberScores[$match->user1_id][1] += $match->user1_league_score;
|
$memberScores[$match->user1_id][1] += $match->user1_league_score;
|
||||||
error_log("+++ ".$match->user1_id." +".$match->user1_league_score);
|
//error_log("+++ ".$match->user1_id." +".$match->user1_league_score);
|
||||||
$memberScores[$match->user1_id][2] += $match->user1_rankscore; // goals
|
$memberScores[$match->user1_id][2] += $match->user1_rankscore; // goals
|
||||||
$memberScores[$match->user1_id][3] += $match->user2_rankscore; // countergoals
|
$memberScores[$match->user1_id][3] += $match->user2_rankscore; // countergoals
|
||||||
|
|
||||||
$memberScores[$match->user2_id][1] += $match->user2_league_score;
|
$memberScores[$match->user2_id][1] += $match->user2_league_score;
|
||||||
error_log("+++ ".$match->user2_id." +".$match->user2_league_score);
|
//error_log("+++ ".$match->user2_id." +".$match->user2_league_score);
|
||||||
$memberScores[$match->user2_id][2] += $match->user2_rankscore; // goals
|
$memberScores[$match->user2_id][2] += $match->user2_rankscore; // goals
|
||||||
$memberScores[$match->user2_id][3] += $match->user1_rankscore; // countergoals
|
$memberScores[$match->user2_id][3] += $match->user1_rankscore; // countergoals
|
||||||
}
|
}
|
||||||
|
|
@ -182,12 +181,12 @@ class League extends Model
|
||||||
|
|
||||||
$leagueScores[$league->id]=$memberScores;
|
$leagueScores[$league->id]=$memberScores;
|
||||||
|
|
||||||
error_log("League::getRanking leagueid / userid / score");
|
//error_log("League::getRanking leagueid / userid / score");
|
||||||
|
|
||||||
foreach ($memberScores as $entry) {
|
foreach ($memberScores as $entry) {
|
||||||
error_log($league->id." / ".$entry[0]." / ".$entry[1]);
|
//error_log($league->id." / ".$entry[0]." / ".$entry[1]);
|
||||||
}
|
}
|
||||||
error_log("---");
|
//error_log("---");
|
||||||
|
|
||||||
}
|
}
|
||||||
return $leagueScores;
|
return $leagueScores;
|
||||||
|
|
@ -281,7 +280,7 @@ class League extends Model
|
||||||
|
|
||||||
$totalRanking[19][4]=2;
|
$totalRanking[19][4]=2;
|
||||||
$uid=$totalRanking[19][0];
|
$uid=$totalRanking[19][0];
|
||||||
Log::info("Abstieg in Liga 2: ["+$uid+"] ".$userNames[$uid]);
|
//Log::info("Abstieg in Liga 2: ["+$uid+"] ".$userNames[$uid]);
|
||||||
|
|
||||||
$totalRanking[20][4]=2;
|
$totalRanking[20][4]=2;
|
||||||
$uid=$totalRanking[20][0];
|
$uid=$totalRanking[20][0];
|
||||||
|
|
@ -493,7 +492,7 @@ class League extends Model
|
||||||
'league_id' => $league_ids[$league_index]
|
'league_id' => $league_ids[$league_index]
|
||||||
]);
|
]);
|
||||||
$leagueMember->save();
|
$leagueMember->save();
|
||||||
error_log("Saving user_id ".$user->id);
|
Log::info("Saving user_id ".$user->id);
|
||||||
$league_index+=1;
|
$league_index+=1;
|
||||||
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
if (sizeof($league_ids)==$league_index) { $league_index=0; }
|
||||||
}
|
}
|
||||||
|
|
@ -511,6 +510,7 @@ class League extends Model
|
||||||
$neededLeagues3=0;
|
$neededLeagues3=0;
|
||||||
|
|
||||||
$league_size1= min(22,$active_member_count);
|
$league_size1= min(22,$active_member_count);
|
||||||
|
Log::info("Creating League 'Spielerliga 1'");
|
||||||
$league1 = League::create([
|
$league1 = League::create([
|
||||||
'is_qualification' => false,
|
'is_qualification' => false,
|
||||||
'name' => 'Spielerliga 1',
|
'name' => 'Spielerliga 1',
|
||||||
|
|
@ -524,6 +524,7 @@ class League extends Model
|
||||||
$league_size2=min(22,$active_member_count - $league_size1);
|
$league_size2=min(22,$active_member_count - $league_size1);
|
||||||
|
|
||||||
if ($league_size2>0) {
|
if ($league_size2>0) {
|
||||||
|
Log::info("Creating League 'Spielerliga 2'");
|
||||||
$league2 = League::create([
|
$league2 = League::create([
|
||||||
'is_qualification' => false,
|
'is_qualification' => false,
|
||||||
'name' => 'Spielerliga 2',
|
'name' => 'Spielerliga 2',
|
||||||
|
|
@ -536,16 +537,15 @@ class League extends Model
|
||||||
array_push($createdLeagues, $league2);
|
array_push($createdLeagues, $league2);
|
||||||
$league_size3 = $active_member_count - $league_size1 - $league_size2;
|
$league_size3 = $active_member_count - $league_size1 - $league_size2;
|
||||||
|
|
||||||
|
Log::info("Size of league 3 = ". $league_size3);
|
||||||
|
|
||||||
// Make neededLeagues3 visible outside of scope
|
// Make neededLeagues3 visible outside of scope
|
||||||
$neededLeagues3=-1;
|
$neededLeagues3=-1;
|
||||||
|
|
||||||
if ($league_size3>0) {
|
if ($league_size3>0) {
|
||||||
$neededLeagues3 = League::neededLeagues($league_size3, $round_count);
|
$neededLeagues3 = League::neededLeagues($league_size3, $round_count);
|
||||||
|
|
||||||
// Wenn es mehr als eine Gruppe ist, mpssen
|
Log::info("Needed 3-Leagues for league_size=".$league_size3." and round_count=".$round_count." is: ".$neededLeagues3);
|
||||||
if ($neededLeagues3>1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($league_nr=1; $league_nr<=$neededLeagues3; $league_nr+=1) {
|
for ($league_nr=1; $league_nr<=$neededLeagues3; $league_nr+=1) {
|
||||||
$league = League::create([
|
$league = League::create([
|
||||||
|
|
@ -677,7 +677,7 @@ class League extends Model
|
||||||
'user_id' => $entry[0],
|
'user_id' => $entry[0],
|
||||||
'league_id' => $league->id
|
'league_id' => $league->id
|
||||||
]);
|
]);
|
||||||
Log::Info("(".$entry[0].") ".$userNames[$entry[0]]." => leagueIndex=".$leagueIndex);
|
Log::info("(".$entry[0].") ".$userNames[$entry[0]]." => leagueIndex=".$leagueIndex);
|
||||||
$leagueMember->save();
|
$leagueMember->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -730,7 +730,7 @@ class League extends Model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// WAS MACHT DIESER CODE ?!
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -835,7 +835,8 @@ class League extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
// WAS MACHT DIESER CODE? --ENDE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class Match extends Model
|
||||||
|
|
||||||
|
|
||||||
public static function getLeagueMatches($leagueId) {
|
public static function getLeagueMatches($leagueId) {
|
||||||
//error_log("App\Match::getLeagueMatches(leagueId=".$leagueId.")");
|
error_log("App\Match::getLeagueMatches(leagueId=".$leagueId.")");
|
||||||
$matches = DB::table('leagues_matches')->where('league_id','=',$leagueId)->orderBy('round_id')->get();
|
$matches = DB::table('leagues_matches')->where('league_id','=',$leagueId)->orderBy('round_id')->get();
|
||||||
$league=League::where('id','=',$leagueId)->first();
|
$league=League::where('id','=',$leagueId)->first();
|
||||||
$season = Season::where('id','=',$league->season_id)->first();
|
$season = Season::where('id','=',$league->season_id)->first();
|
||||||
|
|
@ -123,6 +123,9 @@ class Match extends Model
|
||||||
|
|
||||||
foreach($matches as $match) {
|
foreach($matches as $match) {
|
||||||
//error_log("Needed round_id: ".$match->round_id);
|
//error_log("Needed round_id: ".$match->round_id);
|
||||||
|
//error_log(" User1: ".$match->user1_id);
|
||||||
|
//error_log(" User2: ".$match->user2_id);
|
||||||
|
|
||||||
$match->round_name = $roundnames[$match->round_id];
|
$match->round_name = $roundnames[$match->round_id];
|
||||||
$match->user1_name = $usernames[$match->user1_id];
|
$match->user1_name = $usernames[$match->user1_id];
|
||||||
$match->user2_name = $usernames[$match->user2_id];
|
$match->user2_name = $usernames[$match->user2_id];
|
||||||
|
|
|
||||||
|
|
@ -706,7 +706,7 @@ class Tipp extends Model
|
||||||
|
|
||||||
$quotas=Quota::getQuotas();
|
$quotas=Quota::getQuotas();
|
||||||
|
|
||||||
error_log("Round-Count=".$round_count);
|
Log::debug("Round-Count=".$round_count);
|
||||||
|
|
||||||
if ($round_count==Round::getCount()) {
|
if ($round_count==Round::getCount()) {
|
||||||
// Ranking Payout ausschütten
|
// Ranking Payout ausschütten
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue