From 264b75b5b0b155efdfeeb59c57d61cddd3e40d37 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 31 Jan 2010 23:46:51 +0000 Subject: [PATCH 1/2] fix some sqlite and unicode issues (thanks to Gerko) --- pyfpdb/Filters.py | 3 ++- pyfpdb/GuiGraphViewer.py | 2 +- pyfpdb/SQL.py | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index 7f75cc4e..d5dec059 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -297,7 +297,8 @@ class Filters(threading.Thread): def __set_hero_name(self, w, site): _name = w.get_text() - _guiname = Charset.to_gui(_name) + # get_text() returns a str but we want internal variables to be unicode: + _guiname = unicode(_name) self.heroes[site] = _guiname # print "DEBUG: setting heroes[%s]: %s"%(site, self.heroes[site]) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index ce9648ae..dcfa979c 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -319,7 +319,7 @@ class GuiGraphViewer (threading.Thread): winnings = self.db.cursor.fetchall() self.db.rollback() - if winnings == (): + if len(winnings) == 0: return (None, None, None) green = map(lambda x:float(x[1]), winnings) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 43925c01..7a83ac99 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2021,6 +2021,7 @@ class Sql: elif db_server == 'sqlite': self.query['playerDetailedStats'] = """ select AS hgametypeid + , AS pname ,gt.base ,gt.category AS category ,upper(gt.limitType) AS limittype @@ -2072,6 +2073,7 @@ class Sql: inner join Hands h on (h.id = hp.handId) inner join Gametypes gt on (gt.Id = h.gameTypeId) inner join Sites s on (s.Id = gt.siteId) + inner join Players p on (p.Id = hp.playerId) where hp.playerId in /*and hp.tourneysPlayersId IS NULL*/ From e4c6419074d7ce52b0620c60c0f063448ad0d26d Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 1 Feb 2010 00:17:55 +0000 Subject: [PATCH 2/2] try to improve tourney handling in filter (now displays buyin, but this is not yet used by playerstats when fetching stats --- pyfpdb/Database.py | 3 ++- pyfpdb/Filters.py | 4 ++-- pyfpdb/GuiPlayerStats.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index ebdfceaa..a987b389 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -788,10 +788,11 @@ class Database: def get_player_id(self, config, site, player_name): c = self.connection.cursor() - #print "get_player_id: player_name =", player_name, type(player_name) + print "get_player_id: player_name =", player_name, type(player_name) p_name = Charset.to_utf8(player_name) c.execute(self.sql.query['get_player_id'], (p_name, site)) row = c.fetchone() + print "player id =", row if row: return row[0] else: diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index d5dec059..96245898 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -594,7 +594,7 @@ class Filters(threading.Thread): vbox.pack_start(vbox1, False, False, 0) self.boxes['limits'] = vbox1 - self.cursor.execute(self.sql.query['getLimits2']) + self.cursor.execute(self.sql.query['getLimits3']) # selects limitType, bigBlind result = self.db.cursor.fetchall() found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False} @@ -615,7 +615,7 @@ class Filters(threading.Thread): vbox2.pack_start(hbox, False, False, 0) else: vbox3.pack_start(hbox, False, False, 0) - if line[0] == 'ring': + if True: #line[0] == 'ring': if line[1] == 'fl': name = str(line[2]) found['fl'] = True diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 11b14274..cb94859d 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -526,7 +526,7 @@ class GuiPlayerStats (threading.Thread): if type == 'ring': bbtest = bbtest + " and gt.type = 'ring' " elif type == 'tour': - bbtest = bbtest + " and gt.type = 'tour' " + bbtest = " and gt.type = 'tour' " query = query.replace("", bbtest) if holecards: # re-use level variables for hole card query