prepare for all players display

This commit is contained in:
sqlcoder 2009-10-18 17:18:07 +01:00
parent 0ccc204c89
commit 6453154ef6
2 changed files with 53 additions and 21 deletions

View File

@ -82,6 +82,7 @@ class GuiPlayerStats (threading.Thread):
self.columns = [ ["game", True, "Game", 0.0, "%s"] self.columns = [ ["game", True, "Game", 0.0, "%s"]
, ["hand", False, "Hand", 0.0, "%s"] # true not allowed for this line , ["hand", False, "Hand", 0.0, "%s"] # true not allowed for this line
, ["plposition", False, "Posn", 1.0, "%s"] # true not allowed for this line (set in code) , ["plposition", False, "Posn", 1.0, "%s"] # true not allowed for this line (set in code)
, ["pname", False, "Name", 0.0, "%s"] # true not allowed for this line (set in code)
, ["n", True, "Hds", 1.0, "%d"] , ["n", True, "Hds", 1.0, "%d"]
, ["avgseats", False, "Seats", 1.0, "%3.1f"] , ["avgseats", False, "Seats", 1.0, "%3.1f"]
, ["vpip", True, "VPIP", 1.0, "%3.1f"] , ["vpip", True, "VPIP", 1.0, "%3.1f"]
@ -125,8 +126,9 @@ class GuiPlayerStats (threading.Thread):
self.stats_vbox = None self.stats_vbox = None
self.detailFilters = [] # the data used to enhance the sql select self.detailFilters = [] # the data used to enhance the sql select
self.main_hbox = gtk.HBox(False, 0) #self.main_hbox = gtk.HBox(False, 0)
self.main_hbox.show() #self.main_hbox.show()
self.main_hbox = gtk.HPaned()
self.stats_frame = gtk.Frame() self.stats_frame = gtk.Frame()
self.stats_frame.show() self.stats_frame.show()
@ -136,8 +138,11 @@ class GuiPlayerStats (threading.Thread):
self.stats_frame.add(self.stats_vbox) self.stats_frame.add(self.stats_vbox)
# self.fillStatsFrame(self.stats_vbox) # self.fillStatsFrame(self.stats_vbox)
self.main_hbox.pack_start(self.filters.get_vbox()) #self.main_hbox.pack_start(self.filters.get_vbox())
self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True) #self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
self.main_hbox.pack1(self.filters.get_vbox())
self.main_hbox.pack2(self.stats_frame)
self.main_hbox.show()
# make sure Hand column is not displayed # make sure Hand column is not displayed
[x for x in self.columns if x[0] == 'hand'][0][1] = False [x for x in self.columns if x[0] == 'hand'][0][1] = False
@ -149,7 +154,8 @@ class GuiPlayerStats (threading.Thread):
def refreshStats(self, widget, data): def refreshStats(self, widget, data):
try: self.stats_vbox.destroy() try: self.stats_vbox.destroy()
except AttributeError: pass except AttributeError: pass
self.stats_vbox = gtk.VBox(False, 0) #self.stats_vbox = gtk.VBox(False, 0)
self.stats_vbox = gtk.VPaned()
self.stats_vbox.show() self.stats_vbox.show()
self.stats_frame.add(self.stats_vbox) self.stats_frame.add(self.stats_vbox)
self.fillStatsFrame(self.stats_vbox) self.fillStatsFrame(self.stats_vbox)
@ -192,27 +198,44 @@ class GuiPlayerStats (threading.Thread):
def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates): def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates):
starttime = time() starttime = time()
#groups['allplayers'] = True # testing
# Scrolled window for summary table
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.show()
#vbox.pack_start(swin, expand=True, padding=3)
vbox.pack1(swin)
vbox1 = gtk.VBox(False, 0)
vbox1.show()
swin.add_with_viewport(vbox1)
# Display summary table at top of page # Display summary table at top of page
# 3rd parameter passes extra flags, currently includes: # 3rd parameter passes extra flags, currently includes:
# holecards - whether to display card breakdown (True/False) # holecards - whether to display card breakdown (True/False)
flags = [False] flags = [False]
self.addTable(vbox, 'playerDetailedStats', flags, playerids, sitenos, limits, type, seats, groups, dates) self.addTable(vbox1, 'playerDetailedStats', flags, playerids, sitenos, limits, type, seats, groups, dates)
# Only display one section if all players being shown (query currently too slow for startcards)
if 'allplayers' in groups and groups['allplayers']:
return
# Separator # Separator
sep = gtk.HSeparator() #sep = gtk.HSeparator()
vbox.pack_start(sep, expand=False, padding=3) #vbox.pack_start(sep, expand=False, padding=3)
sep.show_now() #sep.show_now()
vbox.show_now() #vbox.show_now()
heading = gtk.Label(self.filterText['handhead']) #heading = gtk.Label(self.filterText['handhead'])
heading.show() #heading.show()
vbox.pack_start(heading, expand=False, padding=3) #vbox.pack_start(heading, expand=False, padding=3)
# Scrolled window for detailed table (display by hand) # Scrolled window for detailed table (display by hand)
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.show() swin.show()
vbox.pack_start(swin, expand=True, padding=3) #vbox.pack_start(swin, expand=True, padding=3)
vbox.pack2(swin)
vbox1 = gtk.VBox(False, 0) vbox1 = gtk.VBox(False, 0)
vbox1.show() vbox1.show()
@ -326,13 +349,18 @@ class GuiPlayerStats (threading.Thread):
if not flags: holecards = False if not flags: holecards = False
else: holecards = flags[0] else: holecards = flags[0]
if playerids: if 'allplayers' in groups and groups['allplayers']:
nametest = str(tuple(playerids)) nametest = "(select id from players)"
nametest = nametest.replace("L", "") # set flag in self.columns to show player name column
nametest = nametest.replace(",)",")") [x for x in self.columns if x[0] == 'pname'][0][1] = True
query = query.replace("<player_test>", nametest)
else: else:
query = query.replace("<player_test>", "1 = 2") if playerids:
nametest = str(tuple(playerids))
nametest = nametest.replace("L", "")
nametest = nametest.replace(",)",")")
else:
nametest = "1 = 2"
query = query.replace("<player_test>", nametest)
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']))

View File

@ -1807,6 +1807,7 @@ class Sql:
elif db_server == 'postgresql': elif db_server == 'postgresql':
self.query['playerDetailedStats'] = """ self.query['playerDetailedStats'] = """
select <hgameTypeId> AS hgametypeid select <hgameTypeId> AS hgametypeid
,p.name AS pname
,gt.base ,gt.base
,gt.category ,gt.category
,upper(gt.limitType) AS limittype ,upper(gt.limitType) AS limittype
@ -1857,6 +1858,7 @@ class Sql:
inner join Hands h on (h.id = hp.handId) inner join Hands h on (h.id = hp.handId)
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)
inner join Players p on (p.Id = hp.playerId)
where hp.playerId in <player_test> where hp.playerId in <player_test>
/*and hp.tourneysPlayersId IS NULL*/ /*and hp.tourneysPlayersId IS NULL*/
and h.seats <seats_test> and h.seats <seats_test>
@ -1864,6 +1866,7 @@ class Sql:
<gtbigBlind_test> <gtbigBlind_test>
and to_char(h.handStart, 'YYYY-MM-DD') <datestest> and to_char(h.handStart, 'YYYY-MM-DD') <datestest>
group by hgameTypeId group by hgameTypeId
,pname
,hp.playerId ,hp.playerId
,gt.base ,gt.base
,gt.category ,gt.category
@ -1871,7 +1874,8 @@ class Sql:
,plposition ,plposition
,upper(gt.limitType) ,upper(gt.limitType)
,s.name ,s.name
order by hp.playerId order by pname
,hp.playerId
,gt.base ,gt.base
,gt.category ,gt.category
<orderbyseats> <orderbyseats>