From c06eff1c328a4ec270f15685a945cc3ba5eb612a Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 22 Jan 2018 16:06:53 +0100 Subject: Providing default value for match score in config --- jfr_playoff/data.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'jfr_playoff') diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py index 23f82b8..51948cd 100644 --- a/jfr_playoff/data.py +++ b/jfr_playoff/data.py @@ -144,6 +144,9 @@ class PlayoffData(object): else '??' for team in match_teams]) else: teams[i].name = '' + if 'score' in match: + for i in range(0, 2): + teams[i].score = match['score'][i] return teams def get_match_info(self, match): @@ -176,14 +179,16 @@ class PlayoffData(object): info.running = int(row[1]) if row[1] >= row[0] - towels[0]: info.running = 0 - if info.teams[0].score > info.teams[1].score: - info.winner = info.teams[0].name - info.loser = info.teams[1].name - else: - info.loser = info.teams[0].name - info.winner = info.teams[1].name except (mysql.connector.Error, TypeError, KeyError): pass + if (info.running == 0) and \ + ((info.teams[0].score != 0) or (info.teams[1].score != 0)): + if info.teams[0].score > info.teams[1].score: + info.winner = info.teams[0].name + info.loser = info.teams[1].name + else: + info.loser = info.teams[0].name + info.winner = info.teams[1].name return info def prefill_leaderboard(self, teams): -- cgit v1.2.3