playerStats query from sqlcoder - massive whitepsace churn - Apologies

This commit is contained in:
Worros 2008-12-03 17:00:11 +09:00
parent e7650427b0
commit bac92f7b6e

View File

@ -30,13 +30,6 @@ class FpdbSQLQueries:
self.query = {}
self.dbname = db
#Boilerplate code.
# if(self.dbname == 'MySQL InnoDB'):
# self.query[''] = """ """
# elif(self.dbname == 'PostgreSQL'):
# elif(self.dbname == 'SQLite'):
################################
# List tables
################################
@ -642,6 +635,77 @@ class FpdbSQLQueries:
GROUP BY hp.handId, hp.winnings, h.handStart
ORDER BY h.handStart"""
if(self.dbname == 'MySQL InnoDB'):
self.query['playerStats'] = """
SELECT stats.gametypeId
,stats.base
,stats.limitType
,stats.name
,format(stats.bigBlind/100,2) as BigBlind
,stats.n
,stats.vpip
,stats.pfr
,stats.saw_f
,stats.sawsd
,stats.wtsdwsf
,stats.wmsd
,stats.FlAFq
,stats.TuAFq
,stats.RvAFq
,stats.PFAFq
,hprof2.sum_profit/100 as Net
,(hprof2.sum_profit/stats.bigBlind)/(stats.n/100) as BBlPer100
FROM
(select # stats from hudcache
gt.base
,upper(gt.limitType) limitType
,s.name
,gt.bigBlind
,hc.gametypeId
,sum(HDs) as n
,round(100*sum(street0VPI)/sum(HDs)) as vpip
,round(100*sum(street0Aggr)/sum(HDs)) as pfr
,round(100*sum(street1Seen)/sum(HDs)) AS saw_f
,round(100*sum(sawShowdown)/sum(HDs)) AS sawsd
,round(100*sum(sawShowdown)/sum(street1Seen)) AS wtsdwsf
,round(100*sum(wonAtSD)/sum(sawShowdown)) AS wmsd
,round(100*sum(street1Aggr)/sum(street1Seen)) AS FlAFq
,round(100*sum(street2Aggr)/sum(street2Seen)) AS TuAFq
,round(100*sum(street3Aggr)/sum(street3Seen)) AS RvAFq
,round(100*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))) AS PFAFq
from Gametypes gt
inner join Sites s on s.Id = gt.siteId
inner join HudCache hc on hc.gameTypeId = gt.Id
where gt.limittype = 'nl'
and hc.playerId in (3) # use <player_test> here?
# use <gametype_test> here ?
group by hc.gametypeId
) stats
inner join
( select # profit from handsplayers/handsactions
hprof.gameTypeId, sum(hprof.profit) sum_profit
from
(select hp.handId, h.gameTypeId, 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) # use <player_test> here?
# use <gametype_test> here ?
and hp.tourneysPlayersId IS NULL
group by hp.handId, h.gameTypeId, hp.position, hp.winnings
) hprof
group by hprof.gameTypeId
) hprof2
on hprof2.gameTypeId = stats.gameTypeId
order by stats.base, stats.limittype, stats.bigBlind"""
elif(self.dbname == 'PostgreSQL'):
self.query['playerStats'] = """ """
elif(self.dbname == 'SQLite'):
self.query['playerStats'] = """ """
if(self.dbname == 'MySQL InnoDB'):
self.query['playerStatsByPosition'] = """
SELECT stats.gametypeId
@ -734,9 +798,9 @@ class FpdbSQLQueries:
order by stats.base, stats.limittype, stats.bigBlind, stats.pl_position, BBlPer100 desc
"""
elif(self.dbname == 'PostgreSQL'):
self.query = """ """
self.query['playerStatsByPosition'] = """ """
elif(self.dbname == 'SQLite'):
self.query = """ """
self.query['playerStatsByPosition'] = """ """
if __name__== "__main__":
from optparse import OptionParser