Fix Spieleranzeige

This commit is contained in:
Torsten 2019-01-02 16:59:19 +01:00
parent 0cd764cc0e
commit 21c5278270
3 changed files with 22 additions and 17 deletions

View file

@ -159,18 +159,22 @@ class UsersController extends Controller
} else { } else {
if (array_key_exists($user->id, $missingTipps["MISSING_TIPP"])) { if (array_key_exists($user->id, $missingTipps["MISSING_TIPP"])) {
Log::info("..adding missing tipp");
$users[$index]->missingTippText = "Tipps fehlen"; $users[$index]->missingTippText = "Tipps fehlen";
$users[$index]->tippStyling = "red"; $users[$index]->tippStyling = "red";
} else { } else {
Log::info("..adding existing tipp");
$users[$index]->missingTippText = "Runde getippt"; $users[$index]->missingTippText = "Runde getippt";
$users[$index]->tippStyling = "green"; $users[$index]->tippStyling = "green";
} }
Log::info("UsersController.index: Joker Display Check for UserId=".$user->id);
if (array_key_exists($user->id, $missingTipps["MISSING_JOKER"])) { if (array_key_exists($user->id, $missingTipps["MISSING_JOKER"])) {
Log::info("UsersController.index: MISSING JOKER DETECTED -> ".$user->id);
$users[$index]->missingJokerText = "Joker fehlt"; $users[$index]->missingJokerText = "Joker fehlt";
$users[$index]->jokerStyling = "red"; $users[$index]->jokerStyling = "red";
} else { } else {
Log::info("UsersController.index: JOKER EXISTS -> ".$user->id);
$users[$index]->missingJokerText = "Joker gesetzt"; $users[$index]->missingJokerText = "Joker gesetzt";
$users[$index]->jokerStyling = "green"; $users[$index]->jokerStyling = "green";
} }

View file

@ -148,8 +148,6 @@ class Round extends Model
} }
} }
return null; return null;
} }

View file

@ -144,28 +144,35 @@ class User extends Authenticatable
public static function getMissingTippsAndJokers($users) { public static function getMissingTippsAndJokers($users) {
$round = Round::getFirstTippableRound(); $round = Round::getFirstTippableRound();
if (!$round) { if (!$round) {
Log::info("User::getMissingTippsandJokers(users) => no tippable round exists");
$result=array(); $result=array();
$result["MISSING_TIPP"]=array(); $result["MISSING_TIPP"]=array();
$result["MISSING_JOKER"]=array(); $result["MISSING_JOKER"]=array();
return $result; return $result;
} }
Log::info("User::getMissingTippsandJokers(users) => first tippable round= [".$round->id."] ".$round->name);
$tippClock=new TimeLogger("User::getMissingTippsAndJokers()"); $tippClock=new TimeLogger("User::getMissingTippsAndJokers()");
Log::info($tippClock->getStartMessage()); Log::info($tippClock->getStartMessage());
// expecting collection of user db objects like: $users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get(); // expecting collection of user db objects like: $users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get();
$idlist = array();
$usersWithoutJoker=array(); $usersWithoutJoker=array();
foreach($users as $key => $user) { foreach($users as $key => $user) {
array_push($idlist,$key); //array_push($usersWithoutJoker,$user->id);
array_push($usersWithoutJoker,$key); $usersWithoutJoker[$user->id]="";
} }
$games = Game::where('round_id','=',$round->id)->get(); $games = Game::where('round_id','=',$round->id)->get();
$gameIds=array(); $gameIds=array();
foreach ($games as $key => $game) { foreach ($games as $key => $game) { // Vorsicht: $key ist nur der Array index, nicht die game id
array_push($gameIds,$key); array_push($gameIds,$game->id);
Log::info("GAME_ID:".$key); Log::info("GAME_ID:".$game->id);
} }
$tipps = Tipp::whereIn('game_id', $gameIds)->get(); $tipps = Tipp::whereIn('game_id', $gameIds)->get();
@ -175,26 +182,22 @@ class User extends Authenticatable
foreach($tipps as $tipp) { foreach($tipps as $tipp) {
if ($tipp->score1 == -1 || $tipp->score2 == -1) { if ($tipp->score1 == -1 || $tipp->score2 == -1) {
$usersWithoutTipps[$tipp->user_id]="no_tipp"; $usersWithoutTipps[$tipp->user_id]="no_tipp";
Log::info("UserId ".$tipp->user_id." is missing a tipp!"); //Log::info("UserId ".$tipp->user_id." is missing a tipp!");
} }
if ($tipp->joker == true) { if ($tipp->joker == true) {
Log::info("Removing from jokerlist: ".$tipp->user_id); Log::info("Removing from usersWithoutJokerlist: ".$tipp->user_id);
unset($usersWithoutJoker[$tipp->user_id]); unset($usersWithoutJoker[$tipp->user_id]);
} }
} }
foreach ($usersWithoutJoker as $id) { foreach ($usersWithoutJoker as $key => $id) {
Log::info("Jokerless:".$id); Log::info("Jokerless:".$key);
} }
$result=array(); $result=array();
$result["MISSING_TIPP"]=$usersWithoutTipps; $result["MISSING_TIPP"]=$usersWithoutTipps;
$result["MISSING_JOKER"]=$usersWithoutJoker; $result["MISSING_JOKER"]=$usersWithoutJoker;
Log::info("USERLIST: ".implode(",",$idlist));
Log::info($tippClock->getEndMessage());
foreach(array_keys($result) as $key => $value) { foreach(array_keys($result) as $key => $value) {
Log::info("Main key: ".$key.", value=".$value); Log::info("Main key: ".$key.", value=".$value);
} }