diff options
author | emkael <emkael@tlen.pl> | 2018-01-26 16:07:17 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-01-26 16:07:17 +0100 |
commit | 1ab2a54071b270b7e368a3cf02a43436097882f4 (patch) | |
tree | 77778e1e30fbb496dd443ba5e118542a5f760677 | |
parent | f16d79a728b29a445b2292c812dd56c24541c73b (diff) |
Distinguishing matches not yet played, but with carry-over from matches already finished
-rw-r--r-- | jfr_playoff/data.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py index 30862bf..6a58ee6 100644 --- a/jfr_playoff/data.py +++ b/jfr_playoff/data.py @@ -153,6 +153,7 @@ class PlayoffData(object): info.id = match['id'] info.winner_matches = [] info.loser_matches = [] + info.running = 0 for i in range(0, 2): if 'winner' in match['teams'][i]: info.winner_matches += match['teams'][i]['winner'] @@ -165,6 +166,8 @@ class PlayoffData(object): info.teams = self.get_db_match_teams(match) except (mysql.connector.Error, TypeError, IndexError): info.teams = self.get_config_match_teams(match) + if (info.teams[0].score != 0) or (info.teams[1].score != 0): + info.running = -1 try: towels = self.database.fetch( match['database'], p_sql.TOWEL_COUNT, @@ -176,12 +179,12 @@ class PlayoffData(object): (match['table'], match['round']))] if row[1] > 0: info.running = int(row[1]) - if row[1] >= row[0] - towels[0]: - info.running = 0 + if row[0] > 0: + if row[1] >= row[0] - towels[0]: + info.running = -1 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.running == -1): if info.teams[0].score > info.teams[1].score: info.winner = info.teams[0].name info.loser = info.teams[1].name |