added a game selector to the player stats.

This commit is contained in:
unknown 2010-01-20 18:27:11 +01:00 committed by Worros
parent 4187561e66
commit ea423f6b2c
3 changed files with 80 additions and 20 deletions

View File

@ -56,7 +56,7 @@ class Filters(threading.Thread):
,'limitstitle':'Limits:', 'seatstitle':'Number of Players:' ,'limitstitle':'Limits:', 'seatstitle':'Number of Players:'
,'groupstitle':'Grouping:', 'posnshow':'Show Position Stats:' ,'groupstitle':'Grouping:', 'posnshow':'Show Position Stats:'
,'groupsall':'All Players' ,'groupsall':'All Players'
,'limitsFL':'FL', 'limitsNL':'NL', 'ring':'Ring', 'tour':'Tourney' ,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'ring':'Ring', 'tour':'Tourney'
} }
# For use in date ranges. # For use in date ranges.
@ -107,6 +107,7 @@ class Filters(threading.Thread):
self.cbAllLimits = None self.cbAllLimits = None
self.cbFL = None self.cbFL = None
self.cbNL = None self.cbNL = None
self.cbPL = None
self.rb = {} # radio buttons for ring/tour self.rb = {} # radio buttons for ring/tour
self.type = None # ring/tour self.type = None # ring/tour
self.types = {} # list of all ring/tour values self.types = {} # list of all ring/tour values
@ -191,6 +192,9 @@ class Filters(threading.Thread):
def getSites(self): def getSites(self):
return self.sites return self.sites
def getGames(self):
return self.games
def getSiteIds(self): def getSiteIds(self):
return self.siteid return self.siteid
@ -303,7 +307,7 @@ class Filters(threading.Thread):
#print w.get_active() #print w.get_active()
self.limits[limit] = w.get_active() self.limits[limit] = w.get_active()
print "self.limit[%s] set to %s" %(limit, self.limits[limit]) print "self.limit[%s] set to %s" %(limit, self.limits[limit])
if limit.isdigit() or (len(limit) > 2 and limit[-2:] == 'nl'): if limit.isdigit() or (len(limit) > 2 and (limit[-2:] == 'nl' or limit[-2:] == 'fl' or limit[-2:] == 'pl')):
if self.limits[limit]: if self.limits[limit]:
if self.cbNoLimits is not None: if self.cbNoLimits is not None:
self.cbNoLimits.set_active(False) self.cbNoLimits.set_active(False)
@ -314,9 +318,12 @@ class Filters(threading.Thread):
if limit.isdigit(): if limit.isdigit():
if self.cbFL is not None: if self.cbFL is not None:
self.cbFL.set_active(False) self.cbFL.set_active(False)
else: elif (len(limit) > 2 and (limit[-2:] == 'nl')):
if self.cbNL is not None: if self.cbNL is not None:
self.cbNL.set_active(False) self.cbNL.set_active(False)
else:
if self.cbPL is not None:
self.cbPL.set_active(False)
elif limit == "all": elif limit == "all":
if self.limits[limit]: if self.limits[limit]:
#for cb in self.cbLimits.values(): #for cb in self.cbLimits.values():
@ -325,6 +332,8 @@ class Filters(threading.Thread):
self.cbFL.set_active(True) self.cbFL.set_active(True)
if self.cbNL is not None: if self.cbNL is not None:
self.cbNL.set_active(True) self.cbNL.set_active(True)
if self.cbPL is not None:
self.cbPL.set_active(True)
elif limit == "none": elif limit == "none":
if self.limits[limit]: if self.limits[limit]:
for cb in self.cbLimits.values(): for cb in self.cbLimits.values():
@ -333,6 +342,8 @@ class Filters(threading.Thread):
self.cbNL.set_active(False) self.cbNL.set_active(False)
if self.cbFL is not None: if self.cbFL is not None:
self.cbFL.set_active(False) self.cbFL.set_active(False)
if self.cbPL is not None:
self.cbPL.set_active(False)
elif limit == "fl": elif limit == "fl":
if not self.limits[limit]: if not self.limits[limit]:
# only toggle all fl limits off if they are all currently on # only toggle all fl limits off if they are all currently on
@ -384,6 +395,30 @@ class Filters(threading.Thread):
self.rb['tour'].set_active(True) self.rb['tour'].set_active(True)
elif self.type == 'tour': elif self.type == 'tour':
self.rb['ring'].set_active(True) self.rb['ring'].set_active(True)
elif limit == "pl":
if not self.limits[limit]:
# only toggle all nl limits off if they are all currently on
# this stops turning one off from cascading into 'nl' box off
# and then all nl limits being turned off
all_nl_on = True
for cb in self.cbLimits.values():
t = cb.get_children()[0].get_text()
if "pl" in t and len(t) > 2:
if not cb.get_active():
all_nl_on = False
found = {'ring':False, 'tour':False}
for cb in self.cbLimits.values():
t = cb.get_children()[0].get_text()
if "pl" in t and len(t) > 2:
if self.limits[limit] or all_nl_on:
cb.set_active(self.limits[limit])
found[self.types[t]] = True
if self.limits[limit]:
if not found[self.type]:
if self.type == 'ring':
self.rb['tour'].set_active(True)
elif self.type == 'tour':
self.rb['ring'].set_active(True)
elif limit == "ring": elif limit == "ring":
print "set", limit, "to", self.limits[limit] print "set", limit, "to", self.limits[limit]
if self.limits[limit]: if self.limits[limit]:
@ -479,7 +514,7 @@ class Filters(threading.Thread):
self.cursor.execute(self.sql.query['getLimits2']) self.cursor.execute(self.sql.query['getLimits2'])
# selects limitType, bigBlind # selects limitType, bigBlind
result = self.db.cursor.fetchall() result = self.db.cursor.fetchall()
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False} found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False}
if len(result) >= 1: if len(result) >= 1:
hbox = gtk.HBox(True, 0) hbox = gtk.HBox(True, 0)
@ -497,9 +532,13 @@ class Filters(threading.Thread):
vbox2.pack_start(hbox, False, False, 0) vbox2.pack_start(hbox, False, False, 0)
else: else:
vbox3.pack_start(hbox, False, False, 0) vbox3.pack_start(hbox, False, False, 0)
if line[0] == 'ring':
if line[1] == 'fl': if line[1] == 'fl':
name = str(line[2]) name = str(line[2])
found['fl'] = True found['fl'] = True
elif line[1] == 'pl':
name = str(line[2])+line[1]
found['pl'] = True
else: else:
name = str(line[2])+line[1] name = str(line[2])+line[1]
found['nl'] = True found['nl'] = True
@ -532,6 +571,9 @@ class Filters(threading.Thread):
hbox = gtk.HBox(False, 0) hbox = gtk.HBox(False, 0)
vbox3.pack_start(hbox, False, False, 0) vbox3.pack_start(hbox, False, False, 0)
self.cbNL = self.createLimitLine(hbox, 'nl', self.filterText['limitsNL']) self.cbNL = self.createLimitLine(hbox, 'nl', self.filterText['limitsNL'])
hbox = gtk.HBox(False, 0)
vbox3.pack_start(hbox, False, False, 0)
self.cbPL = self.createLimitLine(hbox, 'pl', self.filterText['limitsPL'])
dest = vbox2 # for ring/tour buttons dest = vbox2 # for ring/tour buttons
else: else:
print "INFO: No games returned from database" print "INFO: No games returned from database"

View File

@ -64,7 +64,7 @@ class GuiPlayerStats (threading.Thread):
filters_display = { "Heroes" : True, filters_display = { "Heroes" : True,
"Sites" : True, "Sites" : True,
"Games" : False, "Games" : True,
"Limits" : True, "Limits" : True,
"LimitSep" : True, "LimitSep" : True,
"LimitType" : True, "LimitType" : True,
@ -180,6 +180,7 @@ class GuiPlayerStats (threading.Thread):
seats = self.filters.getSeats() seats = self.filters.getSeats()
groups = self.filters.getGroups() groups = self.filters.getGroups()
dates = self.filters.getDates() dates = self.filters.getDates()
games = self.filters.getGames()
sitenos = [] sitenos = []
playerids = [] playerids = []
@ -205,9 +206,9 @@ class GuiPlayerStats (threading.Thread):
print "No limits found" print "No limits found"
return return
self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates) self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates, games)
def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates): def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates, games):
starttime = time() starttime = time()
# Scrolled window for summary table # Scrolled window for summary table
@ -223,7 +224,7 @@ class GuiPlayerStats (threading.Thread):
# gridnum - index for grid data structures # gridnum - index for grid data structures
flags = [False, self.filters.getNumHands(), 0] flags = [False, self.filters.getNumHands(), 0]
self.addGrid(swin, 'playerDetailedStats', flags, playerids self.addGrid(swin, 'playerDetailedStats', flags, playerids
,sitenos, limits, type, seats, groups, dates) ,sitenos, limits, type, seats, groups, dates, games)
# Separator # Separator
vbox2 = gtk.VBox(False, 0) vbox2 = gtk.VBox(False, 0)
@ -243,7 +244,7 @@ class GuiPlayerStats (threading.Thread):
flags[0] = True flags[0] = True
flags[2] = 1 flags[2] = 1
self.addGrid(swin, 'playerDetailedStats', flags, playerids self.addGrid(swin, 'playerDetailedStats', flags, playerids
,sitenos, limits, type, seats, groups, dates) ,sitenos, limits, type, seats, groups, dates, games)
self.db.rollback() self.db.rollback()
print "Stats page displayed in %4.2f seconds" % (time() - starttime) print "Stats page displayed in %4.2f seconds" % (time() - starttime)
@ -317,7 +318,7 @@ class GuiPlayerStats (threading.Thread):
print "***sortcols error: " + str(sys.exc_info()[1]) print "***sortcols error: " + str(sys.exc_info()[1])
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] ) print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates): def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
counter = 0 counter = 0
row = 0 row = 0
sqlrow = 0 sqlrow = 0
@ -325,7 +326,7 @@ class GuiPlayerStats (threading.Thread):
else: holecards,grid = flags[0],flags[2] else: holecards,grid = flags[0],flags[2]
tmp = self.sql.query[query] tmp = self.sql.query[query]
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates) tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
self.cursor.execute(tmp) self.cursor.execute(tmp)
result = self.cursor.fetchall() result = self.cursor.fetchall()
colnames = [desc[0].lower() for desc in self.cursor.description] colnames = [desc[0].lower() for desc in self.cursor.description]
@ -428,7 +429,7 @@ class GuiPlayerStats (threading.Thread):
#end def addGrid(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates): #end def addGrid(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates):
def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates): def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
having = '' having = ''
if not flags: if not flags:
holecards = False holecards = False
@ -466,6 +467,20 @@ class GuiPlayerStats (threading.Thread):
query = query.replace("<playerName>", pname) query = query.replace("<playerName>", pname)
query = query.replace("<havingclause>", having) query = query.replace("<havingclause>", having)
gametest = ""
q = []
for m in self.filters.display.items():
if m[0] == 'Games' and m[1]:
for n in games:
if games[n]:
q.append(n)
gametest = str(tuple(q))
gametest = gametest.replace("L", "")
gametest = gametest.replace(",)",")")
gametest = gametest.replace("u'","'")
gametest = "and gt.category in %s" % gametest
query = query.replace("<game_test>", gametest)
if seats: if seats:
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to'])) query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
if 'show' in seats and seats['show']: if 'show' in seats and seats['show']:

View File

@ -1881,6 +1881,7 @@ class Sql:
inner join Sites s on (s.Id = gt.siteId) inner join Sites s on (s.Id = gt.siteId)
inner join Players p on (p.Id = hp.playerId) inner join Players p on (p.Id = hp.playerId)
where hp.playerId in <player_test> where hp.playerId in <player_test>
<game_test>
/*and hp.tourneysPlayersId IS NULL*/ /*and hp.tourneysPlayersId IS NULL*/
and h.seats <seats_test> and h.seats <seats_test>
<flagtest> <flagtest>
@ -1964,6 +1965,7 @@ class Sql:
inner join Sites s on (s.Id = gt.siteId) inner join Sites s on (s.Id = gt.siteId)
inner join Players p on (p.Id = hp.playerId) inner join Players p on (p.Id = hp.playerId)
where hp.playerId in <player_test> where hp.playerId in <player_test>
<game_test>
/*and hp.tourneysPlayersId IS NULL*/ /*and hp.tourneysPlayersId IS NULL*/
and h.seats <seats_test> and h.seats <seats_test>
<flagtest> <flagtest>
@ -2047,6 +2049,7 @@ class Sql:
inner join Gametypes gt on (gt.Id = h.gameTypeId) inner join Gametypes gt on (gt.Id = h.gameTypeId)
inner join Sites s on (s.Id = gt.siteId) inner join Sites s on (s.Id = gt.siteId)
where hp.playerId in <player_test> where hp.playerId in <player_test>
<game_test>
/*and hp.tourneysPlayersId IS NULL*/ /*and hp.tourneysPlayersId IS NULL*/
and h.seats <seats_test> and h.seats <seats_test>
<flagtest> <flagtest>