Merge branch 'master' of git://git.assembla.com/fpdboz.git
Conflicts: pyfpdb/fpdb_simple.py
This commit is contained in:
commit
a6544f5d10
|
@ -637,7 +637,8 @@ class FpdbSQLQueries:
|
||||||
|
|
||||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||||
SELECT hp.handId, hp.winnings, SUM(ha.amount), hp.winnings - SUM(ha.amount)
|
SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount)
|
||||||
|
, hp.winnings - (coalesce(hp.ante,0) + SUM(ha.amount))
|
||||||
FROM HandsPlayers hp
|
FROM HandsPlayers hp
|
||||||
INNER JOIN Players pl ON hp.playerId = pl.id
|
INNER JOIN Players pl ON hp.playerId = pl.id
|
||||||
INNER JOIN Hands h ON h.id = hp.handId
|
INNER JOIN Hands h ON h.id = hp.handId
|
||||||
|
@ -645,7 +646,7 @@ class FpdbSQLQueries:
|
||||||
WHERE pl.name = %s
|
WHERE pl.name = %s
|
||||||
AND pl.siteId = %s
|
AND pl.siteId = %s
|
||||||
AND hp.tourneysPlayersId IS NULL
|
AND hp.tourneysPlayersId IS NULL
|
||||||
GROUP BY hp.handId, hp.winnings, h.handStart
|
GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante
|
||||||
ORDER BY h.handStart"""
|
ORDER BY h.handStart"""
|
||||||
elif(self.dbname == 'SQLite'):
|
elif(self.dbname == 'SQLite'):
|
||||||
#Probably doesn't work.
|
#Probably doesn't work.
|
||||||
|
@ -663,11 +664,15 @@ class FpdbSQLQueries:
|
||||||
|
|
||||||
if(self.dbname == 'MySQL InnoDB'):
|
if(self.dbname == 'MySQL InnoDB'):
|
||||||
self.query['playerStats'] = """
|
self.query['playerStats'] = """
|
||||||
SELECT stats.gametypeId
|
SELECT
|
||||||
,stats.base
|
concat(upper(stats.limitType), ' '
|
||||||
,stats.limitType
|
,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' '
|
||||||
,stats.name
|
,stats.name, ' $'
|
||||||
,format(stats.bigBlind/100,2) as BigBlind
|
,cast(trim(leading ' ' from
|
||||||
|
case when stats.bigBlind < 100 then format(stats.bigBlind/100.0,2)
|
||||||
|
else format(stats.bigBlind/100.0,0)
|
||||||
|
end ) as char)
|
||||||
|
) AS Game
|
||||||
,stats.n
|
,stats.n
|
||||||
,stats.vpip
|
,stats.vpip
|
||||||
,stats.pfr
|
,stats.pfr
|
||||||
|
@ -678,36 +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
|
||||||
,upper(gt.limitType) limitType
|
,gt.category
|
||||||
|
,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
|
||||||
|
@ -719,7 +753,7 @@ class FpdbSQLQueries:
|
||||||
costs, hp.winnings - SUM(ha.amount) profit
|
costs, hp.winnings - SUM(ha.amount) profit
|
||||||
from HandsPlayers hp
|
from HandsPlayers hp
|
||||||
inner join Hands h ON h.id = hp.handId
|
inner join Hands h ON h.id = hp.handId
|
||||||
inner join HandsActions ha ON ha.handPlayerId = hp.id
|
left join HandsActions ha ON ha.handPlayerId = hp.id
|
||||||
where hp.playerId in <player_test>
|
where hp.playerId in <player_test>
|
||||||
# use <gametype_test> here ?
|
# use <gametype_test> here ?
|
||||||
and hp.tourneysPlayersId IS NULL
|
and hp.tourneysPlayersId IS NULL
|
||||||
|
@ -728,14 +762,16 @@ 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 stats.gametypeId
|
SELECT upper(stats.limitType) || ' '
|
||||||
,stats.base
|
|| initcap(stats.category) || ' '
|
||||||
,stats.limitType
|
|| stats.name || ' $'
|
||||||
,stats.name
|
|| trim(leading ' ' from
|
||||||
,(stats.bigBlind/100) as BigBlind
|
case when stats.bigBlind < 100 then to_char(stats.bigBlind/100.0,'0D00')
|
||||||
|
else to_char(stats.bigBlind/100.0,'99990')
|
||||||
|
end ) AS Game
|
||||||
,stats.n
|
,stats.n
|
||||||
,stats.vpip
|
,stats.vpip
|
||||||
,stats.pfr
|
,stats.pfr
|
||||||
|
@ -746,34 +782,59 @@ 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
|
||||||
|
/*,to_char(hprof2.sum_profit/100.0,'9G999G990D00') AS Net
|
||||||
|
,to_char((hprof2.sum_profit/(stats.bigBlind+0.0)) / (stats.n/100.0), '990D00')
|
||||||
|
AS BBper100
|
||||||
|
,hprof2.profitperhand AS Profitperhand
|
||||||
|
*/
|
||||||
,hprof2.variance as Variance
|
,hprof2.variance as Variance
|
||||||
FROM
|
FROM
|
||||||
(select gt.base
|
(select gt.base
|
||||||
|
,gt.category
|
||||||
,upper(gt.limitType) as 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
|
,to_char(100.0*sum(street0VPI)/sum(HDs),'90D0') AS vpip
|
||||||
,round(100*sum(street0Aggr)/sum(HDs)) as pfr
|
,to_char(100.0*sum(street0Aggr)/sum(HDs),'90D0') AS pfr
|
||||||
,round(100*sum(street1Seen)/sum(HDs)) AS saw_f
|
,to_char(100.0*sum(street1Seen)/sum(HDs),'90D0') AS saw_f
|
||||||
,round(100*sum(sawShowdown)/sum(HDs)) AS sawsd
|
,to_char(100.0*sum(sawShowdown)/sum(HDs),'90D0') 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 to_char(100.0*sum(sawShowdown)/sum(street1Seen),'90D0')
|
||||||
,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 to_char(100.0*sum(wonAtSD)/sum(sawShowdown),'90D0')
|
||||||
,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 to_char(100.0*sum(street1Aggr)/sum(street1Seen),'90D0')
|
||||||
|
end AS FlAFq
|
||||||
|
,case when sum(street2Seen) = 0 then 'oo'
|
||||||
|
else to_char(100.0*sum(street2Aggr)/sum(street2Seen),'90D0')
|
||||||
|
end AS TuAFq
|
||||||
|
,case when sum(street3Seen) = 0 then 'oo'
|
||||||
|
else to_char(100.0*sum(street3Aggr)/sum(street3Seen),'90D0')
|
||||||
|
end AS RvAFq
|
||||||
|
,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then 'oo'
|
||||||
|
else to_char(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
||||||
|
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),'90D0')
|
||||||
|
end AS PoFAFq
|
||||||
|
,to_char(sum(totalProfit)/100.0,'9G999G990D00') AS Net
|
||||||
|
,to_char((sum(totalProfit)/(gt.bigBlind+0.0)) / (sum(HDs)/100.0), '990D00')
|
||||||
|
AS BBper100
|
||||||
|
,to_char(sum(totalProfit) / (sum(HDs)+0.0), '990D0000') 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>
|
||||||
group by gt.base
|
group by gt.base
|
||||||
|
,gt.category
|
||||||
,upper(gt.limitType)
|
,upper(gt.limitType)
|
||||||
,s.name
|
,s.name
|
||||||
,gt.bigBlind
|
,gt.bigBlind
|
||||||
|
@ -781,9 +842,9 @@ class FpdbSQLQueries:
|
||||||
) stats
|
) stats
|
||||||
inner join
|
inner join
|
||||||
( select
|
( select
|
||||||
hprof.gameTypeId, sum(hprof.profit) sum_profit,
|
hprof.gameTypeId, sum(hprof.profit) AS sum_profit,
|
||||||
avg(hprof.profit/100.0) profitperhand,
|
avg(hprof.profit/100.0) AS profitperhand,
|
||||||
variance(hprof.profit/100.0) variance
|
variance(hprof.profit/100.0) AS variance
|
||||||
from
|
from
|
||||||
(select hp.handId,
|
(select hp.handId,
|
||||||
h.gameTypeId,
|
h.gameTypeId,
|
||||||
|
@ -791,8 +852,8 @@ class FpdbSQLQueries:
|
||||||
SUM(ha.amount) as costs,
|
SUM(ha.amount) as costs,
|
||||||
hp.winnings - SUM(ha.amount) as profit
|
hp.winnings - SUM(ha.amount) as profit
|
||||||
from HandsPlayers hp
|
from HandsPlayers hp
|
||||||
inner join Hands h ON h.id = hp.handId
|
inner join Hands h ON (h.id = hp.handId)
|
||||||
inner join HandsActions ha ON ha.handPlayerId = hp.id
|
left join HandsActions ha ON (ha.handPlayerId = hp.id)
|
||||||
where hp.playerId in <player_test>
|
where hp.playerId in <player_test>
|
||||||
and hp.tourneysPlayersId IS NULL
|
and hp.tourneysPlayersId IS NULL
|
||||||
group by hp.handId, h.gameTypeId, hp.position, hp.winnings
|
group by hp.handId, h.gameTypeId, hp.position, hp.winnings
|
||||||
|
@ -806,97 +867,104 @@ class FpdbSQLQueries:
|
||||||
|
|
||||||
if(self.dbname == 'MySQL InnoDB'):
|
if(self.dbname == 'MySQL InnoDB'):
|
||||||
self.query['playerStatsByPosition'] = """
|
self.query['playerStatsByPosition'] = """
|
||||||
SELECT stats.gametypeId
|
select /* stats from hudcache */
|
||||||
,stats.base
|
hc.position
|
||||||
,stats.limitType
|
,sum(HDs) as n
|
||||||
,stats.name
|
,format(round(100.0*sum(street0VPI)/sum(HDs)),1) AS vpip
|
||||||
,format(stats.bigBlind/100,2) as BigBlind
|
,format(round(100.0*sum(street0Aggr)/sum(HDs)),1) AS pfr
|
||||||
,p.name
|
,format(round(100.0*sum(street1Seen)/sum(HDs)),1) AS saw_f
|
||||||
,stats.pl_position
|
,format(round(100.0*sum(sawShowdown)/sum(HDs)),1) AS sawsd
|
||||||
,stats.n
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
,stats.vpip
|
else format(round(100.0*sum(sawShowdown)/sum(street1Seen)),1)
|
||||||
,stats.pfr
|
end AS wtsdwsf
|
||||||
,stats.saw_f
|
,case when sum(sawShowdown) = 0 then 'oo'
|
||||||
,stats.sawsd
|
else format(round(100.0*sum(wonAtSD)/sum(sawShowdown)),1)
|
||||||
,stats.wtsdwsf
|
end AS wmsd
|
||||||
,stats.wmsd
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
,stats.FlAFq
|
else format(round(100.0*sum(street1Aggr)/sum(street1Seen)),1)
|
||||||
,stats.TuAFq
|
end AS FlAFq
|
||||||
,stats.RvAFq
|
,case when sum(street2Seen) = 0 then 'oo'
|
||||||
,stats.PFAFq
|
else format(round(100.0*sum(street2Aggr)/sum(street2Seen)),1)
|
||||||
,hprof2.sum_profit/100 as Net
|
end AS TuAFq
|
||||||
,(hprof2.sum_profit/stats.bigBlind)/(stats.n/100) as BBlPer100
|
,case when sum(street3Seen) = 0 then 'oo'
|
||||||
# ... any other stats you want to add
|
else format(round(100.0*sum(street3Aggr)/sum(street3Seen)),1)
|
||||||
FROM
|
end AS RvAFq
|
||||||
(select # stats from hudcache
|
,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then 'oo'
|
||||||
hc.playerId
|
else format(round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
||||||
,gt.base
|
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))),1)
|
||||||
,upper(gt.limitType) as limitType
|
end AS PoFAFq
|
||||||
,s.name
|
,format(sum(totalProfit)/100.0,2) AS Net
|
||||||
,gt.bigBlind
|
,case when sum(HDs) = 0 then 'oo'
|
||||||
,hc.gametypeId
|
else format((sum(totalProfit)/(gt.bigBlind+0.0)) / (sum(HDs)/100.0),2)
|
||||||
,case when hc.position = 'B' then -2
|
end AS BBper100
|
||||||
|
from Gametypes gt
|
||||||
|
inner join Sites s on (s.Id = gt.siteId)
|
||||||
|
inner join HudCache hc on (hc.gameTypeId = gt.Id)
|
||||||
|
inner join Players p on (p.id = hc.playerId)
|
||||||
|
where hc.playerId in <player_test>
|
||||||
|
and gt.type = 'ring'
|
||||||
|
and gt.id = <gametype_test> /* must specify gametypeid */
|
||||||
|
/* and stats.n > 100 optional stat-based queries */
|
||||||
|
group by hc.position, gt.bigBlind
|
||||||
|
order by case when hc.position = 'B' then -2
|
||||||
when hc.position = 'S' then -1
|
when hc.position = 'S' then -1
|
||||||
when hc.position = 'D' then 0
|
when hc.position = 'D' then 0
|
||||||
when hc.position = 'C' then 1
|
when hc.position = 'C' then 1
|
||||||
when hc.position = 'M' then 2
|
when hc.position = 'M' then 2
|
||||||
when hc.position = 'E' then 5
|
when hc.position = 'E' then 5
|
||||||
else 9
|
else 9
|
||||||
end as pl_position
|
end
|
||||||
|
"""
|
||||||
|
elif(self.dbname == 'PostgreSQL'):
|
||||||
|
self.query['playerStatsByPosition'] = """
|
||||||
|
select /* stats from hudcache */
|
||||||
|
hc.position AS pl_position
|
||||||
,sum(HDs) as n
|
,sum(HDs) as n
|
||||||
,round(100*sum(street0VPI)/sum(HDs)) as vpip
|
,to_char(round(100.0*sum(street0VPI)/sum(HDs)),'90D0') AS vpip
|
||||||
,round(100*sum(street0Aggr)/sum(HDs)) as pfr
|
,to_char(round(100.0*sum(street0Aggr)/sum(HDs)),'90D0') AS pfr
|
||||||
,round(100*sum(street1Seen)/sum(HDs)) AS saw_f
|
,to_char(round(100.0*sum(street1Seen)/sum(HDs)),'90D0') AS saw_f
|
||||||
,round(100*sum(sawShowdown)/sum(HDs)) AS sawsd
|
,to_char(round(100.0*sum(sawShowdown)/sum(HDs)),'90D0') 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 to_char(round(100.0*sum(sawShowdown)/sum(street1Seen)),'90D0')
|
||||||
,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 to_char(round(100.0*sum(wonAtSD)/sum(sawShowdown)),'90D0')
|
||||||
,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 to_char(round(100.0*sum(street1Aggr)/sum(street1Seen)),'90D0')
|
||||||
|
end AS FlAFq
|
||||||
|
,case when sum(street2Seen) = 0 then 'oo'
|
||||||
|
else to_char(round(100.0*sum(street2Aggr)/sum(street2Seen)),'90D0')
|
||||||
|
end AS TuAFq
|
||||||
|
,case when sum(street3Seen) = 0 then 'oo'
|
||||||
|
else to_char(round(100.0*sum(street3Aggr)/sum(street3Seen)),'90D0')
|
||||||
|
end AS RvAFq
|
||||||
|
,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then 'oo'
|
||||||
|
else to_char(round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
||||||
|
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))),'90D0')
|
||||||
|
end AS PoFAFq
|
||||||
|
,to_char(sum(totalProfit)/100.0,'9G999G990D00') AS Net
|
||||||
|
,case when sum(HDs) = 0 then 'oo'
|
||||||
|
else to_char((sum(totalProfit)/(gt.bigBlind+0.0)) / (sum(HDs)/100.0), '990D00')
|
||||||
|
end AS BBper100
|
||||||
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 gt.limittype = 'nl'
|
inner join Players p on (p.id = hc.playerId)
|
||||||
and hc.playerId in (3) # always specify player for position stats
|
where hc.playerId in <player_test>
|
||||||
# use <gametype_test> here
|
and gt.type = 'ring'
|
||||||
# use <activeseats_test> here
|
and gt.id = <gametype_test> /* must specify gametypeid */
|
||||||
group by hc.playerId, hc.gametypeId, pl_position
|
/* and stats.n > 100 optional stat-based queries */
|
||||||
) stats
|
group by pl_position, gt.bigblind
|
||||||
inner join
|
order by case when hc.position = 'B' then -2
|
||||||
( select # profit from handsplayers/handsactions
|
when hc.position = 'S' then -1
|
||||||
hprof.playerId
|
when hc.position = 'D' then 0
|
||||||
, hprof.gameTypeId
|
when hc.position = 'C' then 1
|
||||||
, case when hprof.position = 'B' then -2
|
when hc.position = 'M' then 2
|
||||||
when hprof.position = 'S' then -1
|
when hc.position = 'E' then 5
|
||||||
when hprof.position in ('3','4') then 2
|
else 9
|
||||||
when hprof.position in ('6','7') then 5
|
end
|
||||||
else hprof.position
|
|
||||||
end as pl_position
|
|
||||||
, sum(hprof.profit) as sum_profit
|
|
||||||
from
|
|
||||||
(select hp.playerId, hp.handId, h.gameTypeId, hp.position, hp.winnings
|
|
||||||
, SUM(ha.amount) costs, hp.winnings - SUM(ha.amount) profit
|
|
||||||
from HandsPlayers hp
|
|
||||||
inner join Hands h ON (h.id = hp.handId)
|
|
||||||
inner join HandsActions ha ON (ha.handPlayerId = hp.id)
|
|
||||||
where hp.playerId in (3) # always specify player for position stats
|
|
||||||
# use <gametype_test> here
|
|
||||||
# use <activeseats_test> here
|
|
||||||
and hp.tourneysPlayersId IS NULL
|
|
||||||
group by hp.playerId, hp.handId, h.gameTypeId, hp.position, hp.winnings
|
|
||||||
) hprof
|
|
||||||
group by hprof.playerId, hprof.gameTypeId, pl_position
|
|
||||||
) hprof2
|
|
||||||
on ( hprof2.gameTypeId = stats.gameTypeId
|
|
||||||
and hprof2.pl_position = stats.pl_position)
|
|
||||||
inner join Players p on (p.id = stats.playerId)
|
|
||||||
where 1 = 1
|
|
||||||
order by stats.base, stats.limittype, stats.bigBlind, stats.pl_position, BBlPer100 desc
|
|
||||||
"""
|
"""
|
||||||
elif(self.dbname == 'PostgreSQL'):
|
|
||||||
self.query['playerStatsByPosition'] = """ """
|
|
||||||
elif(self.dbname == 'SQLite'):
|
elif(self.dbname == 'SQLite'):
|
||||||
self.query['playerStatsByPosition'] = """ """
|
self.query['playerStatsByPosition'] = """ """
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,12 @@ class GuiPlayerStats (threading.Thread):
|
||||||
result = self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[self.activesite],))
|
result = self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[self.activesite],))
|
||||||
result = self.db.cursor.fetchall()
|
result = self.db.cursor.fetchall()
|
||||||
if not result == ():
|
if not result == ():
|
||||||
|
pid = result[0][0]
|
||||||
pid = result[0][0]
|
pid = result[0][0]
|
||||||
tmp = tmp.replace("<player_test>", "(" + str(pid) + ")")
|
tmp = tmp.replace("<player_test>", "(" + str(pid) + ")")
|
||||||
self.cursor.execute(tmp)
|
self.cursor.execute(tmp)
|
||||||
result = self.db.cursor.fetchall()
|
result = self.db.cursor.fetchall()
|
||||||
cols = 20
|
cols = 16
|
||||||
rows = len(result)+1 # +1 for title row
|
rows = len(result)+1 # +1 for title row
|
||||||
self.stats_table = gtk.Table(rows, cols, False)
|
self.stats_table = gtk.Table(rows, cols, False)
|
||||||
self.stats_table.set_col_spacings(4)
|
self.stats_table.set_col_spacings(4)
|
||||||
|
@ -59,7 +60,7 @@ class GuiPlayerStats (threading.Thread):
|
||||||
vbox.add(self.stats_table)
|
vbox.add(self.stats_table)
|
||||||
|
|
||||||
# Create header row
|
# Create header row
|
||||||
titles = ("GID", "base", "Style", "Site", "$BB", "Hands", "VPIP", "PFR", "saw_f", "sawsd", "wtsdwsf", "wmsd", "FlAFq", "TuAFq", "RvAFq", "PFAFq", "Net($)", "BB/100", "$/hand", "Variance")
|
titles = ("Game", "Hands", "VPIP", "PFR", "saw_f", "sawsd", "wtsdwsf", "wmsd", "FlAFq", "TuAFq", "RvAFq", "PFAFq", "Net($)", "BB/100", "$/hand", "Variance")
|
||||||
|
|
||||||
col = 0
|
col = 0
|
||||||
row = 0
|
row = 0
|
||||||
|
@ -77,13 +78,16 @@ class GuiPlayerStats (threading.Thread):
|
||||||
bgcolor = "lightgrey"
|
bgcolor = "lightgrey"
|
||||||
eb = gtk.EventBox()
|
eb = gtk.EventBox()
|
||||||
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
|
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
|
||||||
l = gtk.Label(result[row-1][col])
|
l = gtk.Label(result[row][col])
|
||||||
|
if col == 0:
|
||||||
|
l.set_alignment(xalign=0.0, yalign=0.5)
|
||||||
|
else:
|
||||||
|
l.set_alignment(xalign=1.0, yalign=0.5)
|
||||||
eb.add(l)
|
eb.add(l)
|
||||||
self.stats_table.attach(eb, col, col+1, row+1, row+2)
|
self.stats_table.attach(eb, col, col+1, row+1, row+2)
|
||||||
l.show()
|
l.show()
|
||||||
eb.show()
|
eb.show()
|
||||||
|
|
||||||
|
|
||||||
def fillPlayerFrame(self, vbox):
|
def fillPlayerFrame(self, vbox):
|
||||||
for site in self.conf.supported_sites.keys():
|
for site in self.conf.supported_sites.keys():
|
||||||
hbox = gtk.HBox(False, 0)
|
hbox = gtk.HBox(False, 0)
|
||||||
|
|
|
@ -36,6 +36,7 @@ import math
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
import fpdb_db
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import fpdb_parse_logic
|
import fpdb_parse_logic
|
||||||
from time import time
|
from time import time
|
||||||
|
@ -47,7 +48,7 @@ class Importer:
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
self.caller=caller
|
self.caller=caller
|
||||||
self.config = config
|
self.config = config
|
||||||
self.db = None
|
self.fdb = None
|
||||||
self.cursor = None
|
self.cursor = None
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.dirlist = {}
|
self.dirlist = {}
|
||||||
|
@ -64,35 +65,12 @@ class Importer:
|
||||||
if not self.settings.has_key('handCount'):
|
if not self.settings.has_key('handCount'):
|
||||||
#TODO: Is this value in the xml file?
|
#TODO: Is this value in the xml file?
|
||||||
self.settings['handCount'] = 0
|
self.settings['handCount'] = 0
|
||||||
self.dbConnect()
|
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
|
||||||
|
self.fdb.connect(self.settings['db-backend'],
|
||||||
# XXX: Why is this here, when fpdb_db.connect() already does the
|
self.settings['db-host'],
|
||||||
# same?
|
self.settings['db-databaseName'],
|
||||||
def dbConnect(self):
|
self.settings['db-user'],
|
||||||
#connect to DB
|
self.settings['db-password'])
|
||||||
if self.settings['db-backend'] == 2:
|
|
||||||
if not mysqlLibFound:
|
|
||||||
raise fpdb_simple.FpdbError("interface library MySQLdb not found but MySQL selected as backend - please install the library or change the config file")
|
|
||||||
self.db = MySQLdb.connect(self.settings['db-host'], self.settings['db-user'],
|
|
||||||
self.settings['db-password'], self.settings['db-databaseName'])
|
|
||||||
elif self.settings['db-backend'] == 3:
|
|
||||||
if not pgsqlLibFound:
|
|
||||||
raise fpdb_simple.FpdbError("interface library psycopg2 not found but PostgreSQL selected as backend - please install the library or change the config file")
|
|
||||||
print self.settings
|
|
||||||
if self.settings.has_key('db-host') and \
|
|
||||||
self.settings.has_key('db-user'):
|
|
||||||
self.db = psycopg2.connect(host = self.settings['db-host'],
|
|
||||||
user = self.settings['db-user'],
|
|
||||||
password = self.settings['db-password'],
|
|
||||||
database = self.settings['db-databaseName'])
|
|
||||||
else:
|
|
||||||
dbname = self.settings['db-databaseName']
|
|
||||||
self.db = psycopg2.connect(database = dbname)
|
|
||||||
elif self.settings['db-backend'] == 4:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
self.cursor = self.db.cursor()
|
|
||||||
|
|
||||||
#Set functions
|
#Set functions
|
||||||
def setCallHud(self, value):
|
def setCallHud(self, value):
|
||||||
|
@ -247,12 +225,11 @@ class Importer:
|
||||||
self.hand=hand
|
self.hand=hand
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.db
|
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
||||||
,self.cursor, site, category, hand)
|
,self.fdb.cursor, site, category, hand)
|
||||||
self.db.commit()
|
self.fdb.db.commit()
|
||||||
|
|
||||||
stored+=1
|
stored+=1
|
||||||
self.db.commit()
|
|
||||||
if self.callHud:
|
if self.callHud:
|
||||||
#print "call to HUD here. handsId:",handsId
|
#print "call to HUD here. handsId:",handsId
|
||||||
#pipe the Hands.id out to the HUD
|
#pipe the Hands.id out to the HUD
|
||||||
|
@ -264,17 +241,17 @@ class Importer:
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
if (self.settings['failOnError']):
|
||||||
self.db.commit() #dont remove this, in case hand processing was cancelled.
|
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||||
raise
|
raise
|
||||||
except (fpdb_simple.FpdbError), fe:
|
except (fpdb_simple.FpdbError), fe:
|
||||||
errors+=1
|
errors+=1
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
#fe.printStackTrace() #todo: get stacktrace
|
#fe.printStackTrace() #todo: get stacktrace
|
||||||
self.db.rollback()
|
self.fdb.db.rollback()
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
if (self.settings['failOnError']):
|
||||||
self.db.commit() #dont remove this, in case hand processing was cancelled.
|
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||||
raise
|
raise
|
||||||
if (self.settings['minPrint']!=0):
|
if (self.settings['minPrint']!=0):
|
||||||
if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0):
|
if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0):
|
||||||
|
@ -299,7 +276,7 @@ class Importer:
|
||||||
print "failed to read a single hand from file:", inputFile
|
print "failed to read a single hand from file:", inputFile
|
||||||
handsId=0
|
handsId=0
|
||||||
#todo: this will cause return of an unstored hand number if the last hand was error or partial
|
#todo: this will cause return of an unstored hand number if the last hand was error or partial
|
||||||
self.db.commit()
|
self.fdb.db.commit()
|
||||||
self.handsId=handsId
|
self.handsId=handsId
|
||||||
return handsId
|
return handsId
|
||||||
#end def import_file_dict
|
#end def import_file_dict
|
||||||
|
|
|
@ -135,11 +135,11 @@ def mainParser(backend, db, cursor, site, category, hand):
|
||||||
if base=="hold":
|
if base=="hold":
|
||||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
||||||
, actionTypes, actionAmounts)
|
, actionTypes, actionAmounts, None)
|
||||||
else:
|
else:
|
||||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
||||||
, actionTypes, actionAmounts)
|
, actionTypes, actionAmounts, antes)
|
||||||
|
|
||||||
if isTourney:
|
if isTourney:
|
||||||
ranks=[]
|
ranks=[]
|
||||||
|
|
8
pyfpdb/fpdb_simple.py
Executable file → Normal file
8
pyfpdb/fpdb_simple.py
Executable file → Normal file
|
@ -771,7 +771,7 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo
|
||||||
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
||||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||||
if (line.find("shows")==-1 and line.find("mucked")==-1):
|
if (line.find("shows")==-1):
|
||||||
#print "parseCardLine(in stud if), street:", street
|
#print "parseCardLine(in stud if), street:", street
|
||||||
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
||||||
cardValues[playerNo][street+2]=line[pos:pos+1]
|
cardValues[playerNo][street+2]=line[pos:pos+1]
|
||||||
|
@ -1426,7 +1426,7 @@ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||||
#end def store_hands_players_stud_tourney
|
#end def store_hands_players_stud_tourney
|
||||||
|
|
||||||
def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo
|
def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo
|
||||||
,winnings, totalWinnings, positions, actionTypes, actionAmounts):
|
,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes):
|
||||||
"""calculates data for the HUD during import. IMPORTANT: if you change this method make
|
"""calculates data for the HUD during import. IMPORTANT: if you change this method make
|
||||||
sure to also change the following storage method and table_viewer.prepare_data if necessary
|
sure to also change the following storage method and table_viewer.prepare_data if necessary
|
||||||
"""
|
"""
|
||||||
|
@ -1953,7 +1953,9 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#print "b4 totprof calc, len(playerIds)=", len(player_ids)
|
#print "b4 totprof calc, len(playerIds)=", len(player_ids)
|
||||||
for pl in range (len(player_ids)):
|
for pl in range (len(player_ids)):
|
||||||
#print "pl=", pl
|
#print "pl=", pl
|
||||||
myTotalProfit=winnings[pl] # still need to deduct costs
|
myTotalProfit=winnings[pl] # still need to deduct other costs
|
||||||
|
if antes:
|
||||||
|
myTotalProfit=winnings[pl] - antes[pl]
|
||||||
for i in range (len(actionTypes)): #iterate through streets
|
for i in range (len(actionTypes)): #iterate through streets
|
||||||
#for j in range (len(actionTypes[i])): #iterate through names (using pl loop above)
|
#for j in range (len(actionTypes[i])): #iterate through names (using pl loop above)
|
||||||
for k in range (len(actionTypes[i][pl])): #iterate through individual actions of that player on that street
|
for k in range (len(actionTypes[i][pl])): #iterate through individual actions of that player on that street
|
||||||
|
|
Loading…
Reference in New Issue
Block a user