Working on gshirt payout

This commit is contained in:
Torsten Schneider 2017-12-29 19:08:46 +01:00
parent 16231357b4
commit 9126d54dfb
10 changed files with 507 additions and 108 deletions

View file

@ -261,6 +261,8 @@ class Tipp extends Model
$currentSeason = Season::where('id', '=', $seasonId)->first();
};
if (Round::getLastLockedRoundId()==-1) return null;
// 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.
$sql = "select users.id as user_id, users.name as user_name, ";
@ -357,7 +359,6 @@ class Tipp extends Model
$highestDayscores = array();
foreach ($user_ids as $user_id) {
$totalRankScore = 0;
$foulCount = 0; // Green Shirt Foul Counter
foreach ($round_ids as $round_id) {
$key = $round_id . "_" . $user_id;
// Compute Dayscore values
@ -507,27 +508,28 @@ class Tipp extends Model
}
// B) SET GSCORE TOTAL EVERY ROUND ( and take fouls into consideration )
foreach($user_ids as $user_id) {
$foulCount=0;
$totalScore=0;
foreach ($round_ids as $round_id) {
$key = $round_id . "_" . $user_id;
$score = $roundtipps[$key]['gshirt_score'];
$isFoul = ( $roundtipps[$key]["rankscore"] == 0 );
$isFoul = ( $roundtipps[$key]['rankscore'] == 0 && $totalScore > 0 );
if ($isFoul) {
Log::info("Foul => round_id _ user_id=".$key." / totalRankScore=".$roundtipps[$key]["totalRankScore"]);
$foulCount+=1;
if ($foulCount==3) {
$foulCount=0;
$totalScore=0;
}
}
$lastTotalRankScore=
$totalScore += $score;
$roundtipps[$key]['gshirt_totalscore']=$totalScore;
$roundtipps[$key]['gshirt_foulcount']=$foulCount;
//error_log("Test: key=".$key.", ".$roundtipps[$key]['gshirt_score']);
//Log::info("Test: key=".$key.", ".$roundtipps[$key]['gshirt_score']);
}