From f1729675dc809c51d51c1f43de04717e39a08403 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Mon, 28 Sep 2020 05:47:26 +0200 Subject: [PATCH] implement simple last game check for now --- database.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/database.py b/database.py index bc64d44..ecb4bd7 100644 --- a/database.py +++ b/database.py @@ -29,7 +29,7 @@ class DatabaseConnection: '''Get the total number of players in the database''' cursor = self.connPlayers.cursor() - cursor.execute("SELECT Count(*) FROM players where games >= 10") + cursor.execute("SELECT Count(*) FROM players where games >= 10 and not lastgame is null") count = cursor.fetchone()[0] return count @@ -78,6 +78,7 @@ class DatabaseConnection: cursor = self.connPlayers.cursor() limit = end - start sqlQuery = '''Select * FROM players where games >= 10 + and not lastgame is null ORDER BY (mu - 2*sigma) DESC LIMIT ? OFFSET ?''' cursor.execute(sqlQuery, (limit, start)) rows = cursor.fetchall() @@ -113,7 +114,9 @@ class DatabaseConnection: cursor = self.connPlayers.cursor() if(player.games < 10): return -1 - cursor.execute("SELECT COUNT(*) from players where games >= 10 and (mu-2*sigma) > (?-2*?);", + cursor.execute('''SELECT COUNT(*) from players where games >= 10 + and not lastgame is null + and (mu-2*sigma) > (?-2*?);''', (player.mu, player.sigma)) rank = cursor.fetchone()[0] return rank