playerstats: refine mysql query to stop divide by zero errors and
format figures properly
This commit is contained in:
parent
c533822c96
commit
ef060cd96a
|
@ -683,37 +683,65 @@ class FpdbSQLQueries:
|
||||||
,stats.FlAFq
|
,stats.FlAFq
|
||||||
,stats.TuAFq
|
,stats.TuAFq
|
||||||
,stats.RvAFq
|
,stats.RvAFq
|
||||||
,stats.PFAFq
|
,stats.PoFAFq
|
||||||
,hprof2.sum_profit/100 as Net
|
/* if you have handsactions data the next 3 fields should give same answer as
|
||||||
,(hprof2.sum_profit/stats.bigBlind)/(stats.n/100) as BBlPer100
|
following 3 commented out fields */
|
||||||
,hprof2.profitperhand as Profitperhand
|
,stats.Net
|
||||||
|
,stats.BBper100
|
||||||
|
,stats.Profitperhand
|
||||||
|
/*,format(hprof2.sum_profit/100.0,2) AS Net
|
||||||
|
,format((hprof2.sum_profit/(stats.bigBlind+0.0)) / (stats.n/100.0),2)
|
||||||
|
AS BBlPer100
|
||||||
|
,hprof2.profitperhand AS Profitperhand
|
||||||
|
*/
|
||||||
,hprof2.variance as Variance
|
,hprof2.variance as Variance
|
||||||
FROM
|
FROM
|
||||||
(select # stats from hudcache
|
(select /* stats from hudcache */
|
||||||
gt.base
|
gt.base
|
||||||
,gt.category
|
,gt.category
|
||||||
,upper(gt.limitType) limitType
|
,upper(gt.limitType) as limitType
|
||||||
,s.name
|
,s.name
|
||||||
,gt.bigBlind
|
,gt.bigBlind
|
||||||
,hc.gametypeId
|
,hc.gametypeId
|
||||||
,sum(HDs) as n
|
,sum(HDs) AS n
|
||||||
,round(100*sum(street0VPI)/sum(HDs)) as vpip
|
,format(100.0*sum(street0VPI)/sum(HDs),1) AS vpip
|
||||||
,round(100*sum(street0Aggr)/sum(HDs)) as pfr
|
,format(100.0*sum(street0Aggr)/sum(HDs),1) AS pfr
|
||||||
,round(100*sum(street1Seen)/sum(HDs)) AS saw_f
|
,format(100.0*sum(street1Seen)/sum(HDs),1) AS saw_f
|
||||||
,round(100*sum(sawShowdown)/sum(HDs)) AS sawsd
|
,format(100.0*sum(sawShowdown)/sum(HDs),1) AS sawsd
|
||||||
,round(100*sum(sawShowdown)/sum(street1Seen)) AS wtsdwsf
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
,round(100*sum(wonAtSD)/sum(sawShowdown)) AS wmsd
|
else format(100.0*sum(sawShowdown)/sum(street1Seen),1)
|
||||||
,round(100*sum(street1Aggr)/sum(street1Seen)) AS FlAFq
|
end AS wtsdwsf
|
||||||
,round(100*sum(street2Aggr)/sum(street2Seen)) AS TuAFq
|
,case when sum(sawShowdown) = 0 then 'oo'
|
||||||
,round(100*sum(street3Aggr)/sum(street3Seen)) AS RvAFq
|
else format(100.0*sum(wonAtSD)/sum(sawShowdown),1)
|
||||||
,round(100*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
end AS wmsd
|
||||||
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))) AS PFAFq
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street1Aggr)/sum(street1Seen),1)
|
||||||
|
end AS FlAFq
|
||||||
|
,case when sum(street2Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street2Aggr)/sum(street2Seen),1)
|
||||||
|
end AS TuAFq
|
||||||
|
,case when sum(street3Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street3Aggr)/sum(street3Seen),1)
|
||||||
|
end AS RvAFq
|
||||||
|
,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
||||||
|
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
|
||||||
|
end AS PoFAFq
|
||||||
|
,format(sum(totalProfit)/100.0,2) AS Net
|
||||||
|
,format((sum(totalProfit)/(gt.bigBlind+0.0)) / (sum(HDs)/100.0),2)
|
||||||
|
AS BBper100
|
||||||
|
,format( (sum(totalProfit)/100.0) / sum(HDs), 4) AS Profitperhand
|
||||||
from Gametypes gt
|
from Gametypes gt
|
||||||
inner join Sites s on s.Id = gt.siteId
|
inner join Sites s on s.Id = gt.siteId
|
||||||
inner join HudCache hc on hc.gameTypeId = gt.Id
|
inner join HudCache hc on hc.gameTypeId = gt.Id
|
||||||
where hc.playerId in <player_test>
|
where hc.playerId in <player_test>
|
||||||
# use <gametype_test> here ?
|
# use <gametype_test> here ?
|
||||||
group by hc.gametypeId
|
group by gt.base
|
||||||
|
,gt.category
|
||||||
|
,upper(gt.limitType)
|
||||||
|
,s.name
|
||||||
|
,gt.bigBlind
|
||||||
|
,hc.gametypeId
|
||||||
) stats
|
) stats
|
||||||
inner join
|
inner join
|
||||||
( select # profit from handsplayers/handsactions
|
( select # profit from handsplayers/handsactions
|
||||||
|
@ -734,7 +762,7 @@ class FpdbSQLQueries:
|
||||||
group by hprof.gameTypeId
|
group by hprof.gameTypeId
|
||||||
) hprof2
|
) hprof2
|
||||||
on hprof2.gameTypeId = stats.gameTypeId
|
on hprof2.gameTypeId = stats.gameTypeId
|
||||||
order by stats.base, stats.limittype, stats.bigBlind"""
|
order by stats.category, stats.limittype, stats.bigBlind"""
|
||||||
elif(self.dbname == 'PostgreSQL'):
|
elif(self.dbname == 'PostgreSQL'):
|
||||||
self.query['playerStats'] = """
|
self.query['playerStats'] = """
|
||||||
SELECT upper(stats.limitType) || ' '
|
SELECT upper(stats.limitType) || ' '
|
||||||
|
|
Loading…
Reference in New Issue
Block a user