From fb7aae91862c37bb4a0c56a43d22b1bc6ab82c81 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 27 Jan 2010 13:04:13 +0800 Subject: [PATCH] clean-up code to get playerId in gui-stats and gui-graphs Conflicts: pyfpdb/GuiGraphViewer.py --- pyfpdb/GuiGraphViewer.py | 8 +++----- pyfpdb/GuiPlayerStats.py | 11 ++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 3351b70f..f0eca2f1 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -147,12 +147,10 @@ class GuiGraphViewer (threading.Thread): for site in sites: if sites[site] == True: sitenos.append(siteids[site]) - c = self.db.get_cursor() _hname = Charset.to_utf8(heroes[site]) - c.execute(self.sql.query['getPlayerId'], (_hname,)) - result = c.fetchall() - if len(result) == 1: - playerids.append( int(result[0][0]) ) + result = self.db.get_player_id(self.conf, site, _hname) + if result is not None: + playerids.append(int(result)) if not sitenos: #Should probably pop up here. diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 7a3213e8..13ddf21a 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -41,7 +41,7 @@ class GuiPlayerStats (threading.Thread): self.conf = config self.main_window = mainwin self.sql = querylist - + self.liststore = [] # gtk.ListStore[] stores the contents of the grids self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids @@ -189,13 +189,10 @@ class GuiPlayerStats (threading.Thread): for site in sites: if sites[site] == True: sitenos.append(siteids[site]) - # Nasty hack to deal with multiple sites + same player name -Eric - que = self.sql.query['getPlayerId'] + " AND siteId=%d" % siteids[site] _hname = Charset.to_utf8(heroes[site]) - self.cursor.execute(que, (_hname,)) - result = self.db.cursor.fetchall() - if len(result) == 1: - playerids.append(result[0][0]) + result = self.db.get_player_id(self.conf, site, _hname) + if result is not None: + playerids.append(int(result)) if not sitenos: #Should probably pop up here.