diff --git a/pyfpdb/FpdbSQLQueries.py b/pyfpdb/FpdbSQLQueries.py index c56e6de3..40d0ae6f 100644 --- a/pyfpdb/FpdbSQLQueries.py +++ b/pyfpdb/FpdbSQLQueries.py @@ -576,7 +576,6 @@ class FpdbSQLQueries: if(self.dbname == 'MySQL InnoDB'): self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD INDEX siteTourneyNo(siteTourneyNo)""" elif(self.dbname == 'PostgreSQL'): - # FIXME: This query has a different syntax self.query['addTourneyIndex'] = """CREATE INDEX siteTourneyNo ON Tourneys (siteTourneyNo)""" elif(self.dbname == 'SQLite'): self.query['addHandsIndex'] = """ """ @@ -584,7 +583,6 @@ class FpdbSQLQueries: if(self.dbname == 'MySQL InnoDB'): self.query['addHandsIndex'] = """ALTER TABLE Hands ADD INDEX siteHandNo(siteHandNo)""" elif(self.dbname == 'PostgreSQL'): - # FIXME: This query has a different syntax self.query['addHandsIndex'] = """CREATE INDEX siteHandNo ON Hands (siteHandNo)""" elif(self.dbname == 'SQLite'): self.query['addHandsIndex'] = """ """ @@ -592,7 +590,6 @@ class FpdbSQLQueries: if(self.dbname == 'MySQL InnoDB'): self.query['addPlayersIndex'] = """ALTER TABLE Players ADD INDEX name(name)""" elif(self.dbname == 'PostgreSQL'): - # FIXME: This query has a different syntax self.query['addPlayersIndex'] = """CREATE INDEX name ON Players (name)""" elif(self.dbname == 'SQLite'): self.query['addPlayersIndex'] = """ """ @@ -633,6 +630,11 @@ class FpdbSQLQueries: WHERE Players.name = %s AND HandsPlayers.handId = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" + if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): + self.query['getPlayerId'] = """SELECT id from Players where name = %s""" + elif(self.dbname == 'SQLite'): + self.query['getPlayerId'] = """SELECT id from Players where name = %s""" + if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): self.query['getRingProfitAllHandsPlayerIdSite'] = """ SELECT hp.handId, hp.winnings, SUM(ha.amount), hp.winnings - SUM(ha.amount) @@ -702,8 +704,7 @@ class FpdbSQLQueries: from Gametypes gt inner join Sites s on s.Id = gt.siteId inner join HudCache hc on hc.gameTypeId = gt.Id - where gt.limittype = 'nl' - and hc.playerId in (3) # use here? + where hc.playerId in # use here ? group by hc.gametypeId ) stats @@ -716,7 +717,7 @@ class FpdbSQLQueries: from HandsPlayers hp inner join Hands h ON h.id = hp.handId inner join HandsActions ha ON ha.handPlayerId = hp.id - where hp.playerId in (3) # use here? + where hp.playerId in # use here ? and hp.tourneysPlayersId IS NULL group by hp.handId, h.gameTypeId, hp.position, hp.winnings diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index b6733984..7d689228 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -31,7 +31,9 @@ class GuiPlayerStats (threading.Thread): return self.main_hbox def toggleCallback(self, widget, data=None): - print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()]) +# print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()]) + self.activesite = data + print "DEBUG: activesite set to %s" %(self.activesite) def refreshStats(self, widget, data): try: self.stats_table.destroy() @@ -39,7 +41,14 @@ class GuiPlayerStats (threading.Thread): self.fillStatsFrame(self.stats_frame) def fillStatsFrame(self, vbox): - self.cursor.execute(self.sql.query['playerStats']) + # Get currently active site and grab playerid + tmp = self.sql.query['playerStats'] + + result = self.cursor.execute(self.sql.query['getPlayerId'], self.heroes[self.activesite]) + result = self.db.cursor.fetchall() + pid = result[0][0] + tmp = tmp.replace("", "(" + str(pid) + ")") + self.cursor.execute(tmp) result = self.db.cursor.fetchall() cols = 18 rows = len(result)+1 # +1 for title row @@ -61,7 +70,6 @@ class GuiPlayerStats (threading.Thread): for row in range(rows-1): for col in range(cols): - print "result[%s][%s]: %s" %(row-1, col, result[row-1][col]) if(row%2 == 0): bgcolor = "white" else: @@ -92,10 +100,15 @@ class GuiPlayerStats (threading.Thread): hbox.show() def createPlayerLine(self, hbox, site, player): - button = gtk.RadioButton(None, site + " id:") + if(self.buttongroup == None): + button = gtk.RadioButton(None, site + " id:") + button.set_active(True) + self.buttongroup = button + self.activesite = site + else: + button = gtk.RadioButton(self.buttongroup, site + " id:") hbox.pack_start(button, True, True, 0) button.connect("toggled", self.toggleCallback, site) -# button.set_active(True) button.show() pname = gtk.Entry() @@ -119,6 +132,9 @@ class GuiPlayerStats (threading.Thread): self.sql = querylist + self.activesite = None + self.buttongroup = None + self.heroes = {} self.stat_table = None self.stats_frame = None @@ -138,11 +154,11 @@ class GuiPlayerStats (threading.Thread): statsFrame = gtk.Frame("Stats:") statsFrame.set_label_align(0.0, 0.0) statsFrame.show() - vbox = gtk.VBox(False, 0) - vbox.show() + self.stats_frame = gtk.VBox(False, 0) + self.stats_frame.show() - self.fillStatsFrame(vbox) - statsFrame.add(vbox) + self.fillStatsFrame(self.stats_frame) + statsFrame.add(self.stats_frame) self.main_hbox.pack_start(playerFrame) self.main_hbox.pack_start(statsFrame)