Model refactoring, reducing number of static methods
This commit is contained in:
parent
92a07b1684
commit
bc5ec5edce
7 changed files with 145 additions and 48 deletions
|
|
@ -119,7 +119,6 @@ class UsersController extends Controller
|
|||
|
||||
if($round_id==-1) {
|
||||
$round_id = Round::getLastLockedRoundId();
|
||||
//Log::info("Last complete round id=" . $round_id);
|
||||
if ($round_id==-1) {return redirect("/");}
|
||||
}
|
||||
|
||||
|
|
@ -130,8 +129,29 @@ class UsersController extends Controller
|
|||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
|
||||
foreach($users as $user) {
|
||||
$user->totalScore=0;
|
||||
$user->dayScore=0;
|
||||
$user->totalScore=0; // Summe Ranglisten-Punkte bis heute
|
||||
$user->dayScore=0; // Heute gemachte Ranglisten-Punkte
|
||||
|
||||
$user->dayWinScore=0; // Tagessieg-Punkte, nur exakte Ergebnisse zählen
|
||||
$user->dayWinHighestJoker=0; // Tagessieg-Punkte, nur exakte Ergebnisse zählen
|
||||
|
||||
$round=Round::where('id','=',$round_id)->first();
|
||||
$games=Game::where('round_id','=',$round->id);
|
||||
foreach($games as $game) {
|
||||
$tipp = Tipps::where([['game_id','=',$game->id],['user_id','=',$user->id]])->first();
|
||||
if ($tipp) {
|
||||
$score = Tipp::getDayScoreLocal($game->score1,$game->score2,$tipp->score1,$tipp->score2,$tipp->joker);
|
||||
$scorevalue = intdiv($score,100); // Jokeranteil herausrechnen
|
||||
$jokervalue = $score - $scorevalue*100;
|
||||
$user->dayWinScore+=$scorevalue;
|
||||
|
||||
if ( $jokervalue > $user->dayWinHighestJoker ) {
|
||||
$user->dayWinHighestJoker=$jokervalue;
|
||||
}
|
||||
} else {
|
||||
Log::info("No tipp found for game_id=".$game->id.", user_id=".$user->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rounds=Round::where([['season_id','=',$currentSeason->id],['id','<=',$round_id]])->orderBy('id')->get();
|
||||
|
|
@ -141,12 +161,13 @@ class UsersController extends Controller
|
|||
$index=0;
|
||||
foreach($games as $game) {
|
||||
foreach($users as $user) {
|
||||
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->where('user_id','=',$user->id)->first();
|
||||
if ($tipp) {
|
||||
// Ranglisten-Punkte berechen
|
||||
$score = Tipp::getScoreLocal($game->score1,$game->score2,$tipp->score1,$tipp->score2,$tipp->joker);
|
||||
$user->totalScore += $score;
|
||||
|
||||
|
||||
if ($game->round_id == $round_id) {
|
||||
$user->dayScore += $score;
|
||||
}
|
||||
|
|
@ -155,7 +176,6 @@ class UsersController extends Controller
|
|||
$tippDisplay[$user->id][$game->id][1] = $tipp->score2 ==-1 ? 'x' : $tipp->score2;
|
||||
$tippDisplay[$user->id][$game->id][2] = $tipp->joker;
|
||||
}
|
||||
|
||||
}
|
||||
$index+=1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue