Merge branch 'master' of git://git.assembla.com/fpdb-sql

This commit is contained in:
Worros 2009-05-04 15:02:56 +08:00
commit 04867ea3ef
3 changed files with 60 additions and 23 deletions

View File

@ -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
@ -774,6 +780,9 @@ class FpdbSQLQueries:
,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
,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
@ -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

View File

@ -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

View File

@ -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: