add date filter to player stats
This commit is contained in:
parent
2eb86784fe
commit
c741d720a0
|
@ -900,7 +900,7 @@ class FpdbSQLQueries:
|
|||
GROUP BY h.handStart, hp.handId, hp.totalProfit
|
||||
ORDER BY h.handStart"""
|
||||
|
||||
if self.dbname in ['MySQL InnoDB', 'PostgreSQL']:
|
||||
if self.dbname in ['MySQL InnoDB']:
|
||||
self.query['playerDetailedStats'] = """
|
||||
select <hgameTypeId> AS hgametypeid
|
||||
,gt.base
|
||||
|
@ -957,6 +957,81 @@ class FpdbSQLQueries:
|
|||
and h.seats <seats_test>
|
||||
<flagtest>
|
||||
<gtbigBlind_test>
|
||||
and date_format(h.handStart, '%Y-%m-%d') <datestest>
|
||||
group by hgameTypeId
|
||||
,hp.playerId
|
||||
,gt.base
|
||||
,gt.category
|
||||
<groupbyseats>
|
||||
,upper(gt.limitType)
|
||||
,s.name
|
||||
order by hp.playerId
|
||||
,gt.base
|
||||
,gt.category
|
||||
<orderbyseats>
|
||||
<orderbyhgameTypeId>
|
||||
,maxbigblind desc
|
||||
,upper(gt.limitType)
|
||||
,s.name
|
||||
"""
|
||||
elif self.dbname in ['PostgreSQL']:
|
||||
self.query['playerDetailedStats'] = """
|
||||
select <hgameTypeId> AS hgametypeid
|
||||
,gt.base
|
||||
,gt.category
|
||||
,upper(gt.limitType) AS limittype
|
||||
,s.name
|
||||
,min(gt.bigBlind) AS minbigblind
|
||||
,max(gt.bigBlind) AS maxbigblind
|
||||
/*,<hcgametypeId> AS gtid*/
|
||||
,count(1) AS n
|
||||
,100.0*sum(cast(hp.street0VPI as <signed>integer))/count(1) AS vpip
|
||||
,100.0*sum(cast(hp.street0Aggr as <signed>integer))/count(1) AS pfr
|
||||
,case when sum(cast(hp.street0_3Bchance as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.street0_3Bdone as <signed>integer))/sum(cast(hp.street0_3Bchance as <signed>integer))
|
||||
end AS pf3
|
||||
,case when sum(cast(hp.stealattemptchance as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.stealattempted as <signed>integer))/sum(cast(hp.stealattemptchance as <signed>integer))
|
||||
end AS steals
|
||||
,100.0*sum(cast(hp.street1Seen as <signed>integer))/count(1) AS saw_f
|
||||
,100.0*sum(cast(hp.sawShowdown as <signed>integer))/count(1) AS sawsd
|
||||
,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.sawShowdown as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
|
||||
end AS wtsdwsf
|
||||
,case when sum(cast(hp.sawShowdown as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.wonAtSD as <signed>integer))/sum(cast(hp.sawShowdown as <signed>integer))
|
||||
end AS wmsd
|
||||
,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.street1Aggr as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
|
||||
end AS flafq
|
||||
,case when sum(cast(hp.street2Seen as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.street2Aggr as <signed>integer))/sum(cast(hp.street2Seen as <signed>integer))
|
||||
end AS tuafq
|
||||
,case when sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
|
||||
else 100.0*sum(cast(hp.street3Aggr as <signed>integer))/sum(cast(hp.street3Seen as <signed>integer))
|
||||
end AS rvafq
|
||||
,case when sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
|
||||
else 100.0*(sum(cast(hp.street1Aggr as <signed>integer))+sum(cast(hp.street2Aggr as <signed>integer))+sum(cast(hp.street3Aggr as <signed>integer)))
|
||||
/(sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)))
|
||||
end AS pofafq
|
||||
,sum(hp.totalProfit)/100.0 AS net
|
||||
,sum(hp.rake)/100.0 AS rake
|
||||
,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100
|
||||
,avg(hp.totalProfit)/100.0 AS profitperhand
|
||||
,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr
|
||||
,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr
|
||||
,avg(h.seats+0.0) AS avgseats
|
||||
,variance(hp.totalProfit/100.0) AS variance
|
||||
from HandsPlayers hp
|
||||
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)
|
||||
where hp.playerId in <player_test>
|
||||
and hp.tourneysPlayersId IS NULL
|
||||
and h.seats <seats_test>
|
||||
<flagtest>
|
||||
<gtbigBlind_test>
|
||||
and to_char(h.handStart, 'YYYY-MM-DD') <datestest>
|
||||
group by hgameTypeId
|
||||
,hp.playerId
|
||||
,gt.base
|
||||
|
|
|
@ -60,7 +60,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
"LimitSep" : True,
|
||||
"Seats" : True,
|
||||
"SeatSep" : True,
|
||||
"Dates" : False,
|
||||
"Dates" : True,
|
||||
"Groups" : True,
|
||||
"Button1" : True,
|
||||
"Button2" : True
|
||||
|
@ -93,8 +93,9 @@ class GuiPlayerStats (threading.Thread):
|
|||
, ("rvafq", True, "RvAFq", 1.0, "%3.1f")
|
||||
, ("pofafq", False, "PoFAFq", 1.0, "%3.1f")
|
||||
, ("net", True, "Net($)", 1.0, "%6.2f")
|
||||
, ("bbper100", True, "BB/100", 1.0, "%4.2f")
|
||||
, ("bbper100", True, "bb/100", 1.0, "%4.2f")
|
||||
, ("rake", True, "Rake($)", 1.0, "%6.2f")
|
||||
, ("bb100xr", True, "bbxr/100", 1.0, "%4.2f")
|
||||
, ("variance", True, "Variance", 1.0, "%5.2f")
|
||||
]
|
||||
|
||||
|
@ -155,6 +156,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
siteids = self.filters.getSiteIds()
|
||||
limits = self.filters.getLimits()
|
||||
seats = self.filters.getSeats()
|
||||
dates = self.filters.getDates()
|
||||
sitenos = []
|
||||
playerids = []
|
||||
|
||||
|
@ -178,16 +180,16 @@ class GuiPlayerStats (threading.Thread):
|
|||
print "No limits found"
|
||||
return
|
||||
|
||||
self.createStatsTable(vbox, playerids, sitenos, limits, seats)
|
||||
self.createStatsTable(vbox, playerids, sitenos, limits, seats, dates)
|
||||
|
||||
def createStatsTable(self, vbox, playerids, sitenos, limits, seats):
|
||||
def createStatsTable(self, vbox, playerids, sitenos, limits, seats, dates):
|
||||
starttime = time()
|
||||
|
||||
# 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, seats)
|
||||
self.addTable(vbox, 'playerDetailedStats', flags, playerids, sitenos, limits, seats, dates)
|
||||
|
||||
# Separator
|
||||
sep = gtk.HSeparator()
|
||||
|
@ -210,13 +212,13 @@ class GuiPlayerStats (threading.Thread):
|
|||
|
||||
# Detailed table
|
||||
flags = [True]
|
||||
self.addTable(vbox1, 'playerDetailedStats', flags, playerids, sitenos, limits, seats)
|
||||
self.addTable(vbox1, 'playerDetailedStats', flags, playerids, sitenos, limits, seats, dates)
|
||||
|
||||
self.db.db.commit()
|
||||
print "Stats page displayed in %4.2f seconds" % (time() - starttime)
|
||||
#end def fillStatsFrame(self, vbox):
|
||||
|
||||
def addTable(self, vbox, query, flags, playerids, sitenos, limits, seats):
|
||||
def addTable(self, vbox, query, flags, playerids, sitenos, limits, seats, dates):
|
||||
row = 0
|
||||
sqlrow = 0
|
||||
colalias,colshow,colheading,colxalign,colformat = 0,1,2,3,4
|
||||
|
@ -229,7 +231,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
self.stats_table.show()
|
||||
|
||||
tmp = self.sql.query[query]
|
||||
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, seats)
|
||||
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, seats, dates)
|
||||
self.cursor.execute(tmp)
|
||||
result = self.cursor.fetchall()
|
||||
colnames = [desc[0].lower() for desc in self.cursor.description]
|
||||
|
@ -311,7 +313,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
|
||||
#end def addTable(self, query, vars, playerids, sitenos, limits, seats):
|
||||
|
||||
def refineQuery(self, query, flags, playerids, sitenos, limits, seats):
|
||||
def refineQuery(self, query, flags, playerids, sitenos, limits, seats, dates):
|
||||
if not flags: holecards = False
|
||||
else: holecards = flags[0]
|
||||
|
||||
|
@ -371,6 +373,9 @@ class GuiPlayerStats (threading.Thread):
|
|||
else:
|
||||
query = query.replace("<signed>", '')
|
||||
|
||||
# Filter on dates
|
||||
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
||||
|
||||
#print "query =\n", query
|
||||
return(query)
|
||||
#end def refineQuery(self, query, playerids, sitenos, limits):
|
||||
|
@ -438,3 +443,6 @@ class GuiPlayerStats (threading.Thread):
|
|||
detailDialog.destroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user