From 87f2dde961502130a735912eebe74dc70954e363 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 4 May 2009 02:10:05 +0100 Subject: [PATCH] add 3bet to stats pages and make column and heading choices configurable by editing lists in the init code --- pyfpdb/FpdbSQLQueries.py | 27 +++++++++++++++---- pyfpdb/GuiPlayerStats.py | 4 +-- pyfpdb/GuiPositionalStats.py | 52 +++++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/pyfpdb/FpdbSQLQueries.py b/pyfpdb/FpdbSQLQueries.py index c905170e..d5dc7412 100644 --- a/pyfpdb/FpdbSQLQueries.py +++ b/pyfpdb/FpdbSQLQueries.py @@ -641,6 +641,7 @@ class FpdbSQLQueries: ,stats.n ,stats.vpip ,stats.pfr + ,stats.pf3 ,stats.steals ,stats.saw_f ,stats.sawsd @@ -672,7 +673,11 @@ class FpdbSQLQueries: ,sum(HDs) AS n ,format(100.0*sum(street0VPI)/sum(HDs),1) AS vpip ,format(100.0*sum(street0Aggr)/sum(HDs),1) AS pfr - ,case when sum(stealattemptchance) = 0 then '0' + ,case when sum(street0_3b4bchance) = 0 then '0' + else format(100.0*sum(street0_3b4bdone)/sum(street0_3b4bchance),1) + end AS pf3 + ,case when sum(stealattemptchance) = 0 then '-' + else format(100.0*sum(stealattempted)/sum(stealattemptchance),1) end AS steals ,format(100.0*sum(street1Seen)/sum(HDs),1) AS saw_f @@ -744,6 +749,7 @@ class FpdbSQLQueries: ,stats.n ,stats.vpip ,stats.pfr + ,stats.pf3 ,stats.steals ,stats.saw_f ,stats.sawsd @@ -772,13 +778,16 @@ class FpdbSQLQueries: ,gt.bigBlind ,hc.gametypeId ,sum(HDs) as n - ,to_char(100.0*sum(street0VPI)/sum(HDs),'90D0') AS vpip - ,to_char(100.0*sum(street0Aggr)/sum(HDs),'90D0') AS pfr + ,to_char(100.0*sum(street0VPI)/sum(HDs),'90D0') AS vpip + ,to_char(100.0*sum(street0Aggr)/sum(HDs),'90D0') AS pfr + ,case when sum(street0_3b4bchance) = 0 then '0' + else to_char(100.0*sum(street0_3b4bdone)/sum(street0_3b4bchance),'90D0') + end AS pf3 ,case when sum(stealattemptchance) = 0 then '0' else to_char(100.0*sum(stealattempted)/sum(stealattemptchance),'90D0') end AS steals - ,to_char(100.0*sum(street1Seen)/sum(HDs),'90D0') AS saw_f - ,to_char(100.0*sum(sawShowdown)/sum(HDs),'90D0') AS sawsd + ,to_char(100.0*sum(street1Seen)/sum(HDs),'90D0') AS saw_f + ,to_char(100.0*sum(sawShowdown)/sum(HDs),'90D0') AS sawsd ,case when sum(street1Seen) = 0 then 'oo' else to_char(100.0*sum(sawShowdown)/sum(street1Seen),'90D0') end AS wtsdwsf @@ -860,6 +869,7 @@ class FpdbSQLQueries: ,stats.n ,stats.vpip ,stats.pfr + ,stats.pf3 ,stats.steals ,stats.saw_f ,stats.sawsd @@ -899,6 +909,9 @@ class FpdbSQLQueries: ,sum(HDs) AS n ,format(100.0*sum(street0VPI)/sum(HDs),1) AS vpip ,format(100.0*sum(street0Aggr)/sum(HDs),1) AS pfr + ,case when sum(street0_3b4bchance) = 0 then '0' + else format(100.0*sum(street0_3b4bdone)/sum(street0_3b4bchance),1) + end AS pf3 ,case when sum(stealattemptchance) = 0 then '0' else format(100.0*sum(stealattempted)/sum(stealattemptchance),1) end AS steals @@ -991,6 +1004,7 @@ class FpdbSQLQueries: ,stats.n ,stats.vpip ,stats.pfr + ,stats.pf3 ,stats.steals ,stats.saw_f ,stats.sawsd @@ -1031,6 +1045,9 @@ class FpdbSQLQueries: ,to_char(round(100.0*sum(street0VPI)/sum(HDs)),'90D0') AS vpip ,to_char(round(100.0*sum(street0Aggr)/sum(HDs)),'90D0') AS pfr + ,case when sum(street0_3b4bchance) = 0 then '0' + else to_char(100.0*sum(street0_3b4bdone)/sum(street0_3b4bchance),'90D0') + end AS pf3 ,case when sum(stealattemptchance) = 0 then '0' else to_char(100.0*sum(stealattempted)/sum(stealattemptchance),'90D0') end AS steals diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 0c7729dc..e3ab446c 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -118,7 +118,7 @@ class GuiPlayerStats (threading.Thread): self.cursor.execute(tmp) result = self.cursor.fetchall() - cols = 17 + cols = 18 rows = len(result)+1 # +1 for title row self.stats_table = gtk.Table(rows, cols, False) self.stats_table.set_col_spacings(4) @@ -126,7 +126,7 @@ class GuiPlayerStats (threading.Thread): vbox.add(self.stats_table) # Create header row - titles = ("Game", "Hands", "VPIP", "PFR", "Steals", "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq", "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance") + titles = ("Game", "Hands", "VPIP", "PFR", "PF3", "Steals", "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq", "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance") col = 0 row = 0 diff --git a/pyfpdb/GuiPositionalStats.py b/pyfpdb/GuiPositionalStats.py index 837ec28e..70a877f0 100644 --- a/pyfpdb/GuiPositionalStats.py +++ b/pyfpdb/GuiPositionalStats.py @@ -68,12 +68,27 @@ class GuiPositionalStats (threading.Thread): self.stats_frame = gtk.VBox(False, 0) self.stats_frame.show() + # This could be stored in config eventually, or maybe configured in this window somehow. + # Each posncols element is the name of a column returned by the sql + # query (in lower case) and each posnheads element is the text to use as + # the heading in the GUI. Both sequences should be the same length. + # To miss columns out remove them from both tuples (the 1st 2 elements should always be included). + # To change the heading just edit the second list element as required + # If the first list element does not match a query column that pair is ignored + self.posncols = ( "game", "plposition", "vpip", "pfr", "pf3", "steals" + , "saw_f", "sawsd", "wtsdwsf", "wmsd", "flafq", "tuafq", "rvafq" + , "pofafq", "net", "bbper100", "profitperhand", "variance", "n" ) + self.posnheads = ( "Game", "Posn", "VPIP", "PFR", "PF3", "Steals" + , "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq" + , "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance", "Hds" ) + self.fillStatsFrame(self.stats_frame) statsFrame.add(self.stats_frame) self.main_hbox.pack_start(self.filters.get_vbox()) self.main_hbox.pack_start(statsFrame) + def get_vbox(self): """returns the vbox of this thread""" return self.main_hbox @@ -126,20 +141,18 @@ class GuiPositionalStats (threading.Thread): self.cursor.execute(tmp) result = self.cursor.fetchall() - cols = 18 - rows = len(result) # gtk table expands as required - self.stats_table = gtk.Table(1, cols, False) + self.stats_table = gtk.Table(1, 1, False) # gtk table expands as required self.stats_table.set_col_spacings(4) self.stats_table.show() vbox.add(self.stats_table) - # Create header row - titles = ("Game", "Position", "#", "VPIP", "PFR", "Steals", "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq", "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance") + colnames = [desc[0].lower() for desc in self.cursor.description] + rows = len(result) col = 0 row = 0 - for t in titles: - l = gtk.Label(titles[col]) + for t in self.posnheads: + l = gtk.Label(self.posnheads[col]) l.show() self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK) col +=1 @@ -152,12 +165,16 @@ class GuiPositionalStats (threading.Thread): else: bgcolor = "lightgrey" rowprinted=0 - for col in range(cols): + for col,colname in enumerate(self.posncols): + if colname in colnames: + sqlcol = colnames.index(colname) + else: + continue eb = gtk.EventBox() eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor)) # print blank row between levels: - if result[sqlrow][col] and (sqlrow == 0 or result[sqlrow][0] == last_game): - l = gtk.Label(result[sqlrow][col]) + if result[sqlrow][sqlcol] and (sqlrow == 0 or result[sqlrow][0] == last_game): + l = gtk.Label(result[sqlrow][sqlcol]) rowprinted=1 else: l = gtk.Label(' ') @@ -182,6 +199,7 @@ class GuiPositionalStats (threading.Thread): self.cursor.execute(tmp) result = self.cursor.fetchall() rows = len(result) + colnames = [desc[0].lower() for desc in self.cursor.description] # blank row col = 0 @@ -203,15 +221,17 @@ class GuiPositionalStats (threading.Thread): bgcolor = "white" else: bgcolor = "lightgrey" - inc = 0 - for col in range(cols): + for col,colname in enumerate(self.posncols): + if colname in colnames: + sqlcol = colnames.index(colname) + elif colname != "plposition": + continue eb = gtk.EventBox() eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor)) - if col == 1: + if colname == 'plposition': l = gtk.Label('Totals') - inc = 1 - elif result[sqlrow][col-inc]: - l = gtk.Label(result[sqlrow][col-inc]) + elif result[sqlrow][sqlcol]: + l = gtk.Label(result[sqlrow][sqlcol]) else: l = gtk.Label(' ') if col == 0: