From 6762fb4bd2b02048a5657b0f2c68b279fdd48176 Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 25 Feb 2017 18:44:50 +0100 Subject: Towel support --- playoff.py | 9 +++++---- playoff/sql.py | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/playoff.py b/playoff.py index ec0bb37..6169f5e 100644 --- a/playoff.py +++ b/playoff.py @@ -155,13 +155,14 @@ def get_match_info(match): ) if len([team for team in teams if team is not None]) > 0 else '' try: + towels = db_fetch(match['database'], p_sql.TOWEL_COUNT, (match['table'], match['round'])) row = db_fetch(match['database'], p_sql.BOARD_COUNT, (match['table'], match['round'])) if row[1] > 0: info.running = int(row[1]) - if row[1] == row[0]: - info.running = 0 - info.winner = info.teams[0].name if info.teams[0].score > info.teams[1].score else info.teams[1].name - info.loser = info.teams[1].name if info.teams[0].score > info.teams[1].score else info.teams[0].name + if row[1] >= row[0] - towels[0]: + info.running = 0 + info.winner = info.teams[0].name if info.teams[0].score > info.teams[1].score else info.teams[1].name + info.loser = info.teams[1].name if info.teams[0].score > info.teams[1].score else info.teams[0].name except Exception as e: pass return info diff --git a/playoff/sql.py b/playoff/sql.py index d5c28cd..69cd423 100644 --- a/playoff/sql.py +++ b/playoff/sql.py @@ -22,6 +22,13 @@ JOIN #db#.admin WHERE sc1.tabl = %s AND sc1.rnd = %s ''' +TOWEL_COUNT = ''' +SELECT #db#.admin.boardspersegment * SUM(#db#.segments.towel) +FROM #db#.segments +JOIN #db#.admin +WHERE #db#.segments.tabl = %s AND #db#.segments.rnd = %s +''' + PREFIX = ''' SELECT shortname FROM #db#.admin ''' -- cgit v1.2.3