Fixups to GuiPlayerStats

Now sets up and obeys the radio buttons more correctly.

Also reads the names from the text box, and replaces <player_test> in
the sql query.
This commit is contained in:
Worros 2008-12-07 17:06:01 +09:00
parent 425997d66a
commit 977e954574
2 changed files with 32 additions and 15 deletions

View File

@ -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 <player_test> here?
where hc.playerId in <player_test>
# use <gametype_test> 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 <player_test> here?
where hp.playerId in <player_test>
# use <gametype_test> here ?
and hp.tourneysPlayersId IS NULL
group by hp.handId, h.gameTypeId, hp.position, hp.winnings

View File

@ -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("<player_test>", "(" + 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)