Cached ranking, for rankscore, rankscore_total, dayscore winner
This commit is contained in:
parent
b7f4b2be4e
commit
02e44a4363
2 changed files with 60 additions and 36 deletions
|
|
@ -306,11 +306,28 @@ class UsersController extends Controller
|
|||
$roundtipps[$key]['user_id'] = $entry->user_id;
|
||||
|
||||
$roundtipps[$key]['rankscore']=0;
|
||||
$roundtipps[$key]['dayscore']=Tipp::getDayScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker);
|
||||
$roundtipps[$key]['dayscore']=0;
|
||||
|
||||
$roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff;
|
||||
}
|
||||
$roundtipps[$key]['rankscore']+=Tipp::getScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker);
|
||||
$roundtipps[$key]['rankscore']+=Tipp::getScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker); // Für alle 4 Spiele
|
||||
if ($user_id==1) {Log::info("Calculating rankscore for round_id ".$round_id." to ".$roundtipps[$key]['rankscore']);}
|
||||
|
||||
|
||||
// START: Add Up Dayscore Win Values for each round
|
||||
$tipp_hits = intdiv($roundtipps[$key]['dayscore'],100);
|
||||
$joker_value = $roundtipps[$key]['dayscore'] - $tipp_hits*100;
|
||||
|
||||
$current_score=Tipp::getDayScoreLocal($entry->game_score1,$entry->game_score2,$entry->tipp_score1,$entry->tipp_score2,$entry->joker);
|
||||
$current_tipp_hit = intdiv($current_score,100);
|
||||
$current_joker_value = $current_score - ( $current_tipp_hit * 100 );
|
||||
|
||||
$hits_total = $tipp_hits + $current_tipp_hit;
|
||||
$current_joker_value = max($joker_value,$current_joker_value);
|
||||
$roundtipps[$key]["dayscore"] = $hits_total * 100 + $current_joker_value;
|
||||
// END: Add Up Dayscore Win Values
|
||||
|
||||
|
||||
|
||||
if ($entry->game_kickoff < $roundtipps[$key]['earliest_kickoff']) { $roundtipps[$key]['earliest_kickoff']=$entry->game_kickoff; }
|
||||
|
||||
|
|
@ -318,14 +335,6 @@ class UsersController extends Controller
|
|||
array_push($roundtipps[$key]['results'], $entry->game_score1, $entry->game_score2);
|
||||
}
|
||||
|
||||
//dd($roundtipps);
|
||||
//dd($user_ids);
|
||||
//dd($round_ids);
|
||||
|
||||
//Log::info($user_ids);
|
||||
//Log::info($round_ids);
|
||||
|
||||
|
||||
Log::info("max_round_id=".$max_round_id);
|
||||
|
||||
// Aufbau der Rankingliste in rankingDisplay, sowie aufaddieren der jeweiligen Punkte.
|
||||
|
|
@ -335,24 +344,26 @@ class UsersController extends Controller
|
|||
$payout_sum = 0;
|
||||
|
||||
foreach($round_ids as $round_id) {
|
||||
if ($user_id==1) { Log::info("Accumulating display data for round_id ".$round_id); }
|
||||
$key = $round_id . "_" . $user_id;
|
||||
if ($user_id==1) { Log::info("Processing round: ".$round_id);}
|
||||
if ($user_id==1) { Log::info("Dayscore round: ".$round_id." = ".$roundtipps[$key]['dayscore']);}
|
||||
if ($user_id==1) { Log::info("Rankscore round: ".$round_id." = ".$roundtipps[$key]['rankscore']);}
|
||||
if (!array_key_exists($user_id, $rankingDisplay)) {
|
||||
$rankingDisplay[$user_id] = array();
|
||||
|
||||
|
||||
/*
|
||||
if ($user_id==1) {
|
||||
Log::info("round_id=".$round_id.", rankscore from var=".$roundtipps[$key]["rankscore"]. ", old_total=" .$rankscore_total);
|
||||
}
|
||||
*/
|
||||
$rankingDisplay[$user_id]["user_id"] = $user_id;
|
||||
$rankingDisplay[$user_id]["dayscore"] = 0;
|
||||
|
||||
$rankingDisplay[$user_id]["user_name"] = $roundtipps[$key]["user_name"];
|
||||
$rankingDisplay[$user_id]["is_dayscorewinner"] = 0;
|
||||
|
||||
if ($user_id==1) { Log::info("rankscore after user init for display round_id ".$round_id." = ".$roundtipps[$key]["rankscore"]);}
|
||||
}
|
||||
|
||||
$rankingDisplay[$user_id]["rankscore"] = $rankscore_total + $roundtipps[$key]["rankscore"]; $rankscore_total=$rankingDisplay[$user_id]["rankscore"];
|
||||
$rankingDisplay[$user_id]["rankscore"] = $roundtipps[$key]["rankscore"]; // Summe Rangwertung alle 4 Spiele/Tipps der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
$rankingDisplay[$user_id]["dayscore"] = $roundtipps[$key]["dayscore"]; // Dayscore der letzten durchlaufenen Runde, NICHT in init stellen !!
|
||||
|
||||
$rankingDisplay[$user_id]["rankscore_total"] = $rankscore_total + $roundtipps[$key]["rankscore"];
|
||||
$rankscore_total=$rankingDisplay[$user_id]["rankscore_total"];
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score1"] = $roundtipps[$key]["tipps"][0];
|
||||
$rankingDisplay[$user_id]["tipp_score2"] = $roundtipps[$key]["tipps"][1];
|
||||
|
|
@ -366,7 +377,6 @@ class UsersController extends Controller
|
|||
$roundtipps[$key]["tipps"][0],$roundtipps[$key]["tipps"][1],
|
||||
$roundtipps[$key]["tipps"][2]);
|
||||
|
||||
|
||||
$rankingDisplay[$user_id]["tipp_score3"] = $roundtipps[$key]["tipps"][3];
|
||||
$rankingDisplay[$user_id]["tipp_score4"] = $roundtipps[$key]["tipps"][4];
|
||||
$rankingDisplay[$user_id]["joker2"] = $roundtipps[$key]["tipps"][5];
|
||||
|
|
@ -390,11 +400,8 @@ class UsersController extends Controller
|
|||
$rankingDisplay[$user_id]["trendCol4"] = Tipp::trendCol($roundtipps[$key]["results"][6],$roundtipps[$key]["results"][7],
|
||||
$roundtipps[$key]["tipps"][9],$roundtipps[$key]["tipps"][10],
|
||||
$roundtipps[$key]["tipps"][11]);
|
||||
|
||||
}
|
||||
|
||||
//TODO: Loop: Determine DayScoreWinner, Rank (multiple identical possible), Sort rankingDisplay array
|
||||
|
||||
}
|
||||
|
||||
$userids = array_keys($rankingDisplay);
|
||||
|
|
@ -402,25 +409,37 @@ class UsersController extends Controller
|
|||
$games=Game::where('round_id','=',$max_round_id)->get();
|
||||
$all_rounds=Round::where('season_id','=',$currentSeason->id)->get();
|
||||
|
||||
|
||||
// Sortieren nach Rankscore
|
||||
$entries = array();
|
||||
usort($rankingDisplay, array($this,"cmp2"));
|
||||
|
||||
foreach($rankingDisplay as $entry) {
|
||||
array_push($entries, $entry);
|
||||
}
|
||||
|
||||
$rankingDisplay = $entries;
|
||||
|
||||
// Ranknr identifizieren, inkl, geteilter Rankplatzierungen
|
||||
$lastScore=-1;
|
||||
$lastrank=0;
|
||||
$highest_dayscore=0;
|
||||
foreach($rankingDisplay as $key => $user) {
|
||||
if ($user["rankscore"]==$lastScore) {
|
||||
if ($user["rankscore_total"]==$lastScore) {
|
||||
$rankingDisplay[$key]["rank"] = $lastrank;
|
||||
} else {
|
||||
$lastrank +=1;
|
||||
$rankingDisplay[$key]["rank"] = $lastrank;
|
||||
$lastScore = $user["rankscore"];
|
||||
$lastScore = $user["rankscore_total"];
|
||||
}
|
||||
|
||||
if ($user["dayscore"]>$highest_dayscore) { $highest_dayscore = $user["dayscore"]; }
|
||||
}
|
||||
|
||||
Log::info("Searching for dayscore winners. Highest dayscore=".$highest_dayscore);
|
||||
// is_dayscorewinner setzen (Tagessieg)
|
||||
foreach($rankingDisplay as $key => $user) {
|
||||
if ($user["dayscore"]>0 && $user["dayscore"]==$highest_dayscore) {
|
||||
$rankingDisplay[$key]["is_dayscorewinner"]=1;
|
||||
Log::info("Setting dayscorewin for player:".$user["user_name"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +447,7 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
public function cmp2($user1, $user2) {
|
||||
return ($user1['rankscore'] < $user2['rankscore']);
|
||||
return ($user1['rankscore_total'] < $user2['rankscore_total']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -131,15 +131,19 @@
|
|||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Joker</span>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
<th style="height:140px;white-space: nowrap;">
|
||||
<div style="transform:translate(25px, 51px) rotate(315deg);width:30px;">
|
||||
<span style="border-bottom: 1px solid #ccc; padding: 5px 10px;">Debug (DayWinScore)</span>
|
||||
</div>
|
||||
</th>
|
||||
@foreach($rankingDisplay as $entry)
|
||||
|
||||
<tr>
|
||||
<td class="table-bordered"> <span class="text list-unstyled" href="#" > {{ $entry["rank"] }} </span></td>
|
||||
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/crown.png" style="{{ ($entry["is_dayscorewinner"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
|
||||
<td class="table-bordered"> <a class="text list-unstyled" href="#" style="vertical-align: middle;">{{ $entry["user_name"] }} </a></td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["rankscore_total"] }} </td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["rankscore"] }} </td>
|
||||
<td class="table-bordered" align="center"> {{ $entry["dayscore"] }} </td>
|
||||
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}"> {{ $entry["tipp_score1"] }} </td>
|
||||
<td class="table-bordered" align="center" style="{{$entry["trendCol1"]}}"> {{ $entry["tipp_score2"] }} </td>
|
||||
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/joker.png" style="{{ ($entry["joker1"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
|
||||
|
|
@ -152,6 +156,7 @@
|
|||
<td class="table-bordered" align="center" style="{{$entry["trendCol4"]}}"> {{$entry["tipp_score7"] }} </td>
|
||||
<td class="table-bordered" align="center" style="{{$entry["trendCol4"]}}"> {{$entry["tipp_score8"] }} </td>
|
||||
<td class="table-bordered"><div style="margin: 0 auto; width: 32px;"><img src="/img/joker.png" style="{{ ($entry["joker4"] ? 'float:left;width:32px;height:32px' : 'display: none;') }}"></div></td>
|
||||
<td class="table-bordered" align="center" > {{ $entry["dayscore"] }} </td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue