From 6453154ef6aec454419c2ac46c41d507fa1478bd Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 18 Oct 2009 17:18:07 +0100 Subject: [PATCH] prepare for all players display --- pyfpdb/GuiPlayerStats.py | 68 ++++++++++++++++++++++++++++------------ pyfpdb/SQL.py | 6 +++- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 4b82c861..9d90974c 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -82,6 +82,7 @@ class GuiPlayerStats (threading.Thread): self.columns = [ ["game", True, "Game", 0.0, "%s"] , ["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) + , ["pname", False, "Name", 0.0, "%s"] # true not allowed for this line (set in code) , ["n", True, "Hds", 1.0, "%d"] , ["avgseats", False, "Seats", 1.0, "%3.1f"] , ["vpip", True, "VPIP", 1.0, "%3.1f"] @@ -125,8 +126,9 @@ class GuiPlayerStats (threading.Thread): self.stats_vbox = None self.detailFilters = [] # the data used to enhance the sql select - self.main_hbox = gtk.HBox(False, 0) - self.main_hbox.show() + #self.main_hbox = gtk.HBox(False, 0) + #self.main_hbox.show() + self.main_hbox = gtk.HPaned() self.stats_frame = gtk.Frame() self.stats_frame.show() @@ -136,8 +138,11 @@ class GuiPlayerStats (threading.Thread): self.stats_frame.add(self.stats_vbox) # self.fillStatsFrame(self.stats_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.filters.get_vbox()) + #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 [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): try: self.stats_vbox.destroy() 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_frame.add(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): 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 # 3rd parameter passes extra flags, currently includes: # holecards - whether to display card breakdown (True/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 - sep = gtk.HSeparator() - vbox.pack_start(sep, expand=False, padding=3) - sep.show_now() - vbox.show_now() - heading = gtk.Label(self.filterText['handhead']) - heading.show() - vbox.pack_start(heading, expand=False, padding=3) + #sep = gtk.HSeparator() + #vbox.pack_start(sep, expand=False, padding=3) + #sep.show_now() + #vbox.show_now() + #heading = gtk.Label(self.filterText['handhead']) + #heading.show() + #vbox.pack_start(heading, expand=False, padding=3) # Scrolled window for detailed table (display by hand) 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.pack_start(swin, expand=True, padding=3) + vbox.pack2(swin) vbox1 = gtk.VBox(False, 0) vbox1.show() @@ -326,13 +349,18 @@ class GuiPlayerStats (threading.Thread): if not flags: holecards = False else: holecards = flags[0] - if playerids: - nametest = str(tuple(playerids)) - nametest = nametest.replace("L", "") - nametest = nametest.replace(",)",")") - query = query.replace("", nametest) + if 'allplayers' in groups and groups['allplayers']: + nametest = "(select id from players)" + # set flag in self.columns to show player name column + [x for x in self.columns if x[0] == 'pname'][0][1] = True else: - query = query.replace("", "1 = 2") + if playerids: + nametest = str(tuple(playerids)) + nametest = nametest.replace("L", "") + nametest = nametest.replace(",)",")") + else: + nametest = "1 = 2" + query = query.replace("", nametest) if seats: query = query.replace('', 'between ' + str(seats['from']) + ' and ' + str(seats['to'])) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 629f682e..a226825f 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -1807,6 +1807,7 @@ class Sql: elif db_server == 'postgresql': self.query['playerDetailedStats'] = """ select AS hgametypeid + ,p.name AS pname ,gt.base ,gt.category ,upper(gt.limitType) AS limittype @@ -1857,6 +1858,7 @@ class Sql: inner join Hands h on (h.id = hp.handId) inner join Gametypes gt on (gt.Id = h.gameTypeId) inner join Sites s on (s.Id = gt.siteId) + inner join Players p on (p.Id = hp.playerId) where hp.playerId in /*and hp.tourneysPlayersId IS NULL*/ and h.seats @@ -1864,6 +1866,7 @@ class Sql: and to_char(h.handStart, 'YYYY-MM-DD') group by hgameTypeId + ,pname ,hp.playerId ,gt.base ,gt.category @@ -1871,7 +1874,8 @@ class Sql: ,plposition ,upper(gt.limitType) ,s.name - order by hp.playerId + order by pname + ,hp.playerId ,gt.base ,gt.category