clean-up code to get playerId in gui-stats and gui-graphs

This commit is contained in:
Gerko de Roo 2010-01-26 23:36:38 +01:00
parent b248270135
commit f5c910bff0
2 changed files with 7 additions and 14 deletions

View File

@ -147,14 +147,10 @@ class GuiGraphViewer (threading.Thread):
for site in sites: for site in sites:
if sites[site] == True: if sites[site] == True:
sitenos.append(siteids[site]) sitenos.append(siteids[site])
c = self.db.get_cursor()
_hname = Charset.to_utf8(heroes[site]) _hname = Charset.to_utf8(heroes[site])
# Nasty hack to deal with multiple sites + same player name -Eric result = self.db.get_player_id(self.conf, site, _hname)
que = self.sql.query['getPlayerId'] + " AND siteId=%d" % siteids[site] if result is not None:
c.execute(que, (_hname,)) playerids.append(int(result))
result = c.fetchall()
if len(result) == 1:
playerids.append( int(result[0][0]) )
if not sitenos: if not sitenos:
#Should probably pop up here. #Should probably pop up here.

View File

@ -41,7 +41,7 @@ class GuiPlayerStats (threading.Thread):
self.conf = config self.conf = config
self.main_window = mainwin self.main_window = mainwin
self.sql = querylist self.sql = querylist
self.liststore = [] # gtk.ListStore[] stores the contents of the grids self.liststore = [] # gtk.ListStore[] stores the contents of the grids
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
@ -189,13 +189,10 @@ class GuiPlayerStats (threading.Thread):
for site in sites: for site in sites:
if sites[site] == True: if sites[site] == True:
sitenos.append(siteids[site]) 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]) _hname = Charset.to_utf8(heroes[site])
self.cursor.execute(que, (_hname,)) result = self.db.get_player_id(self.conf, site, _hname)
result = self.db.cursor.fetchall() if result is not None:
if len(result) == 1: playerids.append(int(result))
playerids.append(result[0][0])
if not sitenos: if not sitenos:
#Should probably pop up here. #Should probably pop up here.