summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playoff.py9
-rw-r--r--playoff/sql.py7
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
'''