show unplayed rounds

This commit is contained in:
Torsten 2017-10-02 10:49:15 +02:00
parent 98ebdb6c93
commit 7545760aa2
5 changed files with 47 additions and 29 deletions

View file

@ -174,9 +174,9 @@ class LeaguesController extends Controller
public function showLeagueRounds($league_rank, $maxRoundId) {
if (Auth::guest()) { return redirect("/"); }
$maxRoundId = min(Round::getLastCompleteRoundId(),$maxRoundId);
$season=Season::getCurrent();
$maxRoundId = min(Round::getLastRoundId($season->id),$maxRoundId);
$roundNames = Round::getNames();
$leagueNames = League::getNames();
$leagues = League::where('season_id','=',$season->id)->where('rank','=', $league_rank)->orderBy('id')->get();
@ -198,7 +198,6 @@ class LeaguesController extends Controller
$matchesTotal[$match->round_id][$league->id] = $lg;
}
}
}
return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames'));

View file

@ -116,7 +116,6 @@ class Round extends Model
return $tippSpielLink;
}
// Ab sofort Verzicht auf statische Methoden, soweit möglich.
public function getLockTime() {
@ -153,4 +152,10 @@ class Round extends Model
}
return $roundnames;
}
public static function getLastRoundId($seasonId) {
$round = Round::where('season_id', '=', $seasonId)->orderBy('id','desc')->first(); // get last entry
return $round->id;
}
}

View file

@ -88,13 +88,14 @@ class League extends Model
$matches=Match::getMatchResults($league->id,-1);
foreach ($matches as $match) {
if (!Round::isCompleted($match->round_id)) { continue; }
$memberScores[$match->user1_id][1] += $match->user1_league_score;
$memberScores[$match->user1_id][2] += $match->user1_rankscore;
$memberScores[$match->user1_id][3] += $match->user2_rankscore;
$memberScores[$match->user2_id][1] += $match->user2_league_score;
$memberScores[$match->user2_id][2] += $match->user2_rankscore;
$memberScores[$match->user2_id][3] += $match->user1_rankscore;
if (Round::isCompleted($match->round_id)) {
$memberScores[$match->user1_id][1] += $match->user1_league_score;
$memberScores[$match->user1_id][2] += $match->user1_rankscore;
$memberScores[$match->user1_id][3] += $match->user2_rankscore;
$memberScores[$match->user2_id][1] += $match->user2_league_score;
$memberScores[$match->user2_id][2] += $match->user2_rankscore;
$memberScores[$match->user2_id][3] += $match->user1_rankscore;
}
}
usort($memberScores, array('App\Leagues\League','cmpScore'));

View file

@ -94,7 +94,7 @@ class Match extends Model
$match->round_name = $roundnames[$match->round_id];
$match->user1_name = $usernames[$match->user1_id];
$match->user2_name = $usernames[$match->user2_id];
// Punktauswertung in Match::getResults($leagueId, $maxRoundId);
// Punktauswertung in Match::getMatchResults($leagueId, $maxRoundId);
}
return $matches;
}
@ -156,34 +156,43 @@ class Match extends Model
$roundtipps = Tipp::getRoundTipps($maxRoundId);
$roundtipps = $roundtipps["roundtipps"];
$matches = Match::getLeagueMatches($leagueId, $maxRoundId);
$season = Season::getCurrent();
if ($maxRoundId==-1) {$maxRoundId=Round::getLastCompleteRoundId();}
if ($maxRoundId==-1) { $maxRoundId = Round::getLastRoundId($season->id); }
foreach($matches as $key => $match) {
if (!Round::isCompleted($match->round_id)) continue;
$user1_key = $match->round_id."_".$match->user1_id;
$user2_key = $match->round_id."_".$match->user2_id;
$user1_score = $roundtipps[$user1_key]["rankscore"];
$user2_score = $roundtipps[$user2_key]["rankscore"];
if (Round::isCompleted($match->round_id)) {
$matches[$key]->user1_rankscore = $user1_score;
$matches[$key]->user2_rankscore = $user2_score;
$user1_score = $roundtipps[$user1_key]["rankscore"];
$user2_score = $roundtipps[$user2_key]["rankscore"];
//$matches[$key]->user1_hits = $roundtipps[$user1_key][]
$matches[$key]->user1_rankscore = $user1_score;
$matches[$key]->user2_rankscore = $user2_score;
if ($user1_score > $user2_score) {
$matches[$key]->user1_league_score = 3;
$matches[$key]->user2_league_score = 0;
//$matches[$key]->user1_hits = $roundtipps[$user1_key][]
}
else if ($user1_score < $user2_score){
if ($user1_score > $user2_score) {
$matches[$key]->user1_league_score = 3;
$matches[$key]->user2_league_score = 0;
}
else if ($user1_score < $user2_score){
$matches[$key]->user1_league_score = 0;
$matches[$key]->user2_league_score = 3;
} else {
$matches[$key]->user1_league_score = 1;
$matches[$key]->user2_league_score = 1;
}
} else { // Untipped/future round
$matches[$key]->user1_league_score = 0;
$matches[$key]->user2_league_score = 3;
} else {
$matches[$key]->user1_league_score = 1;
$matches[$key]->user2_league_score = 1;
$matches[$key]->user2_league_score = 0;
$matches[$key]->user1_rankscore = -1;
$matches[$key]->user2_rankscore = -1;
}
}

View file

@ -27,7 +27,11 @@
<tr class="table-bordered">
<td>&nbsp;{{$match->user1_name}}&nbsp;</td>
<td>&nbsp;{{$match->user2_name}}&nbsp;</td>
<td> {{$match->user1_rankscore}}:{{$match->user2_rankscore}}</td>
@if($match->user1_rankscore==-1)
<td> ausstehend </td>
@else
<td> {{$match->user1_rankscore}}:{{$match->user2_rankscore}}</td>
@endif
</tr>
@endforeach