Make Grapher work with limits
This commit is contained in:
parent
dd563aab39
commit
1939979e3c
|
@ -125,6 +125,13 @@ class Filters(threading.Thread):
|
|||
def getHeroes(self):
|
||||
return self.heroes
|
||||
|
||||
def getLimits(self):
|
||||
ltuple = []
|
||||
for l in self.limits:
|
||||
if self.limits[l] == True:
|
||||
ltuple.append(l)
|
||||
return ltuple
|
||||
|
||||
def getDates(self):
|
||||
return self.__get_dates()
|
||||
|
||||
|
|
|
@ -609,7 +609,7 @@ class FpdbSQLQueries:
|
|||
elif(self.dbname == 'SQLite'):
|
||||
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'):
|
||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||
SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount)
|
||||
, hp.winnings - (coalesce(hp.ante,0) + SUM(ha.amount))
|
||||
|
@ -617,28 +617,15 @@ class FpdbSQLQueries:
|
|||
INNER JOIN Players pl ON hp.playerId = pl.id
|
||||
INNER JOIN Hands h ON h.id = hp.handId
|
||||
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
||||
INNER JOIN Gametypes g ON h.gametypeId = g.id
|
||||
where pl.id in <player_test>
|
||||
AND pl.siteId in <site_test>
|
||||
AND h.handStart > '<startdate_test>'
|
||||
AND h.handStart < '<enddate_test>'
|
||||
AND g.bigBlind in <limit_test>
|
||||
AND hp.tourneysPlayersId IS NULL
|
||||
GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante
|
||||
ORDER BY h.handStart"""
|
||||
elif(self.dbname == 'SQLite'):
|
||||
#Probably doesn't work.
|
||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||
SELECT hp.handId, hp.winnings, SUM(ha.amount), hp.winnings - SUM(ha.amount)
|
||||
FROM HandsPlayers hp
|
||||
INNER JOIN Players pl ON hp.playerId = pl.id
|
||||
INNER JOIN Hands h ON h.id = hp.handId
|
||||
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
||||
where pl.id in <player_test>
|
||||
AND pl.siteId in <site_test>
|
||||
AND h.handStart > '<startdate_test>'
|
||||
AND h.handStart < '<enddate_test>'
|
||||
AND hp.tourneysPlayersId IS NULL
|
||||
GROUP BY hp.handId, hp.winnings, h.handStart
|
||||
ORDER BY h.handStart"""
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB'):
|
||||
self.query['playerStats'] = """
|
||||
|
|
|
@ -127,6 +127,7 @@ class GuiGraphViewer (threading.Thread):
|
|||
sites = self.filters.getSites()
|
||||
heroes = self.filters.getHeroes()
|
||||
siteids = self.filters.getSiteIds()
|
||||
limits = self.filters.getLimits()
|
||||
# Which sites are selected?
|
||||
for site in sites:
|
||||
if sites[site] == True:
|
||||
|
@ -141,18 +142,20 @@ class GuiGraphViewer (threading.Thread):
|
|||
print "No sites selected - defaulting to PokerStars"
|
||||
sitenos = [2]
|
||||
|
||||
|
||||
if not playerids:
|
||||
print "No player ids found"
|
||||
return
|
||||
|
||||
if not limits:
|
||||
print "No limits found"
|
||||
return
|
||||
|
||||
#Set graph properties
|
||||
self.ax = self.fig.add_subplot(111)
|
||||
|
||||
#Get graph data from DB
|
||||
starttime = time()
|
||||
line = self.getRingProfitGraph(playerids, sitenos)
|
||||
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
||||
print "Graph generated in: %s" %(time() - starttime)
|
||||
|
||||
self.ax.set_title("Profit graph for ring games")
|
||||
|
@ -182,7 +185,7 @@ class GuiGraphViewer (threading.Thread):
|
|||
self.exportButton.set_sensitive(True)
|
||||
#end of def showClicked
|
||||
|
||||
def getRingProfitGraph(self, names, sites):
|
||||
def getRingProfitGraph(self, names, sites, limits):
|
||||
tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite']
|
||||
# print "DEBUG: getRingProfitGraph"
|
||||
start_date, end_date = self.filters.getDates()
|
||||
|
@ -192,15 +195,19 @@ class GuiGraphViewer (threading.Thread):
|
|||
# [5L] into (5) not (5,) and [5L, 2829L] into (5, 2829)
|
||||
nametest = str(tuple(names))
|
||||
sitetest = str(tuple(sites))
|
||||
limittest = str(tuple(limits))
|
||||
nametest = nametest.replace("L", "")
|
||||
nametest = nametest.replace(",)",")")
|
||||
sitetest = sitetest.replace(",)",")")
|
||||
limittest = limittest.replace("L", "")
|
||||
limittest = limittest.replace(",)",")")
|
||||
|
||||
#Must be a nicer way to deal with tuples of size 1 ie. (2,) - which makes sql barf
|
||||
tmp = tmp.replace("<player_test>", nametest)
|
||||
tmp = tmp.replace("<site_test>", sitetest)
|
||||
tmp = tmp.replace("<startdate_test>", start_date)
|
||||
tmp = tmp.replace("<enddate_test>", end_date)
|
||||
tmp = tmp.replace("<limit_test>", limittest)
|
||||
|
||||
#print "DEBUG: sql query:"
|
||||
#print tmp
|
||||
|
|
Loading…
Reference in New Issue
Block a user