update graph viewer to work with enhanced filter
This commit is contained in:
parent
4b0a399ffd
commit
4d92e3d2a0
|
@ -32,12 +32,13 @@ import FpdbSQLQueries
|
||||||
|
|
||||||
class Filters(threading.Thread):
|
class Filters(threading.Thread):
|
||||||
def __init__(self, db, config, qdict, display = {}, debug=True):
|
def __init__(self, db, config, qdict, display = {}, debug=True):
|
||||||
self.debug=debug
|
# config and qdict are now redundant
|
||||||
|
self.debug = debug
|
||||||
#print "start of GraphViewer constructor"
|
#print "start of GraphViewer constructor"
|
||||||
self.db=db
|
self.db = db
|
||||||
self.cursor=db.cursor
|
self.cursor = db.cursor
|
||||||
self.sql=qdict
|
self.sql = db.sql
|
||||||
self.conf = config
|
self.conf = db.config
|
||||||
self.display = display
|
self.display = display
|
||||||
|
|
||||||
self.sites = {}
|
self.sites = {}
|
||||||
|
@ -451,6 +452,9 @@ class Filters(threading.Thread):
|
||||||
hbox.pack_start(vbox3, False, False, 0)
|
hbox.pack_start(vbox3, False, False, 0)
|
||||||
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
|
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
|
||||||
for i, line in enumerate(result):
|
for i, line in enumerate(result):
|
||||||
|
if "UseType" in self.display:
|
||||||
|
if line[0] != self.display["UseType"]:
|
||||||
|
continue
|
||||||
hbox = gtk.HBox(False, 0)
|
hbox = gtk.HBox(False, 0)
|
||||||
if i <= len(result)/2:
|
if i <= len(result)/2:
|
||||||
vbox2.pack_start(hbox, False, False, 0)
|
vbox2.pack_start(hbox, False, False, 0)
|
||||||
|
|
|
@ -57,16 +57,22 @@ class GuiGraphViewer (threading.Thread):
|
||||||
"Sites" : True,
|
"Sites" : True,
|
||||||
"Games" : True,
|
"Games" : True,
|
||||||
"Limits" : True,
|
"Limits" : True,
|
||||||
|
"LimitSep" : True,
|
||||||
|
"LimitType" : True,
|
||||||
|
"Type" : False,
|
||||||
|
"UseType" : 'ring',
|
||||||
"Seats" : False,
|
"Seats" : False,
|
||||||
|
"SeatSep" : False,
|
||||||
"Dates" : True,
|
"Dates" : True,
|
||||||
|
"Groups" : False,
|
||||||
"Button1" : True,
|
"Button1" : True,
|
||||||
"Button2" : True
|
"Button2" : True
|
||||||
}
|
}
|
||||||
|
|
||||||
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
||||||
self.filters.registerButton1Name("Refresh Graph")
|
self.filters.registerButton1Name("Refresh _Graph")
|
||||||
self.filters.registerButton1Callback(self.generateGraph)
|
self.filters.registerButton1Callback(self.generateGraph)
|
||||||
self.filters.registerButton2Name("Export to File")
|
self.filters.registerButton2Name("_Export to File")
|
||||||
self.filters.registerButton2Callback(self.exportGraph)
|
self.filters.registerButton2Callback(self.exportGraph)
|
||||||
|
|
||||||
self.mainHBox = gtk.HBox(False, 0)
|
self.mainHBox = gtk.HBox(False, 0)
|
||||||
|
@ -146,10 +152,8 @@ class GuiGraphViewer (threading.Thread):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def generateGraph(self, widget, data):
|
def generateGraph(self, widget, data):
|
||||||
print "generateGraph: start"
|
|
||||||
try:
|
try:
|
||||||
self.clearGraphData()
|
self.clearGraphData()
|
||||||
print "after cleardata"
|
|
||||||
|
|
||||||
sitenos = []
|
sitenos = []
|
||||||
playerids = []
|
playerids = []
|
||||||
|
@ -158,15 +162,18 @@ class GuiGraphViewer (threading.Thread):
|
||||||
heroes = self.filters.getHeroes()
|
heroes = self.filters.getHeroes()
|
||||||
siteids = self.filters.getSiteIds()
|
siteids = self.filters.getSiteIds()
|
||||||
limits = self.filters.getLimits()
|
limits = self.filters.getLimits()
|
||||||
print "got filter data"
|
for i in ('show', 'none'):
|
||||||
|
if i in limits:
|
||||||
|
limits.remove(i)
|
||||||
# Which sites are selected?
|
# Which sites are selected?
|
||||||
for site in sites:
|
for site in sites:
|
||||||
if sites[site] == True:
|
if sites[site] == True:
|
||||||
sitenos.append(siteids[site])
|
sitenos.append(siteids[site])
|
||||||
self.db.cursor.execute(self.sql.query['getPlayerId'], (heroes[site],))
|
c = self.db.get_cursor()
|
||||||
result = self.db.cursor.fetchall()
|
c.execute(self.sql.query['getPlayerId'], (heroes[site],))
|
||||||
|
result = c.fetchall()
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
playerids.append(result[0][0])
|
playerids.append( int(result[0][0]) )
|
||||||
|
|
||||||
if not sitenos:
|
if not sitenos:
|
||||||
#Should probably pop up here.
|
#Should probably pop up here.
|
||||||
|
@ -182,12 +189,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
return
|
return
|
||||||
|
|
||||||
#Set graph properties
|
#Set graph properties
|
||||||
print "add_subplot"
|
|
||||||
self.ax = self.fig.add_subplot(111)
|
self.ax = self.fig.add_subplot(111)
|
||||||
|
|
||||||
#Get graph data from DB
|
#Get graph data from DB
|
||||||
starttime = time()
|
starttime = time()
|
||||||
print "get line: playerids =", playerids, "sitenos =", sitenos, "limits =", limits
|
|
||||||
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
||||||
print "Graph generated in: %s" %(time() - starttime)
|
print "Graph generated in: %s" %(time() - starttime)
|
||||||
|
|
||||||
|
@ -234,12 +239,31 @@ class GuiGraphViewer (threading.Thread):
|
||||||
# [5L] into (5) not (5,) and [5L, 2829L] into (5, 2829)
|
# [5L] into (5) not (5,) and [5L, 2829L] into (5, 2829)
|
||||||
nametest = str(tuple(names))
|
nametest = str(tuple(names))
|
||||||
sitetest = str(tuple(sites))
|
sitetest = str(tuple(sites))
|
||||||
limittest = str(tuple(limits))
|
#nametest = nametest.replace("L", "")
|
||||||
nametest = nametest.replace("L", "")
|
|
||||||
nametest = nametest.replace(",)",")")
|
lims = [int(x) for x in limits if x.isdigit()]
|
||||||
sitetest = sitetest.replace(",)",")")
|
nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
|
||||||
limittest = limittest.replace("L", "")
|
limittest = "and ( (gt.limitType = 'fl' and gt.bigBlind in "
|
||||||
limittest = limittest.replace(",)",")")
|
# and ( (limit and bb in()) or (nolimit and bb in ()) )
|
||||||
|
if lims:
|
||||||
|
blindtest = str(tuple(lims))
|
||||||
|
blindtest = blindtest.replace("L", "")
|
||||||
|
blindtest = blindtest.replace(",)",")")
|
||||||
|
limittest = limittest + blindtest + ' ) '
|
||||||
|
else:
|
||||||
|
limittest = limittest + '(-1) ) '
|
||||||
|
limittest = limittest + " or (gt.limitType = 'nl' and gt.bigBlind in "
|
||||||
|
if nolims:
|
||||||
|
blindtest = str(tuple(nolims))
|
||||||
|
blindtest = blindtest.replace("L", "")
|
||||||
|
blindtest = blindtest.replace(",)",")")
|
||||||
|
limittest = limittest + blindtest + ' ) )'
|
||||||
|
else:
|
||||||
|
limittest = limittest + '(-1) ) )'
|
||||||
|
if type == 'ring':
|
||||||
|
limittest = limittest + " and gt.type = 'ring' "
|
||||||
|
elif type == 'tour':
|
||||||
|
limittest = limittest + " and gt.type = 'tour' "
|
||||||
|
|
||||||
#Must be a nicer way to deal with tuples of size 1 ie. (2,) - which makes sql barf
|
#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("<player_test>", nametest)
|
||||||
|
@ -247,6 +271,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
tmp = tmp.replace("<startdate_test>", start_date)
|
tmp = tmp.replace("<startdate_test>", start_date)
|
||||||
tmp = tmp.replace("<enddate_test>", end_date)
|
tmp = tmp.replace("<enddate_test>", end_date)
|
||||||
tmp = tmp.replace("<limit_test>", limittest)
|
tmp = tmp.replace("<limit_test>", limittest)
|
||||||
|
tmp = tmp.replace(",)", ")")
|
||||||
|
|
||||||
#print "DEBUG: sql query:"
|
#print "DEBUG: sql query:"
|
||||||
#print tmp
|
#print tmp
|
||||||
|
@ -255,10 +280,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
winnings = self.db.cursor.fetchall()
|
winnings = self.db.cursor.fetchall()
|
||||||
self.db.rollback()
|
self.db.rollback()
|
||||||
|
|
||||||
if(winnings == ()):
|
if winnings == ():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
y=map(lambda x:float(x[3]), winnings)
|
y = map(lambda x:float(x[1]), winnings)
|
||||||
line = cumsum(y)
|
line = cumsum(y)
|
||||||
return line/100
|
return line/100
|
||||||
#end of def getRingProfitGraph
|
#end of def getRingProfitGraph
|
||||||
|
|
|
@ -2455,16 +2455,16 @@ class Sql:
|
||||||
# self.query['playerStatsByPosition'] = """ """
|
# self.query['playerStatsByPosition'] = """ """
|
||||||
|
|
||||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||||
SELECT hp.handId, hp.totalProfit, hp.totalProfit, hp.totalProfit
|
SELECT hp.handId, hp.totalProfit
|
||||||
FROM HandsPlayers hp
|
FROM HandsPlayers hp
|
||||||
INNER JOIN Players pl ON (hp.playerId = pl.id)
|
INNER JOIN Players pl ON (pl.id = hp.playerId)
|
||||||
INNER JOIN Hands h ON (h.id = hp.handId)
|
INNER JOIN Hands h ON (h.id = hp.handId)
|
||||||
INNER JOIN Gametypes g ON (h.gametypeId = g.id)
|
INNER JOIN Gametypes gt ON (gt.id = h.gametypeId)
|
||||||
where pl.id in <player_test>
|
WHERE pl.id in <player_test>
|
||||||
AND pl.siteId in <site_test>
|
AND pl.siteId in <site_test>
|
||||||
AND h.handStart > '<startdate_test>'
|
AND h.handStart > '<startdate_test>'
|
||||||
AND h.handStart < '<enddate_test>'
|
AND h.handStart < '<enddate_test>'
|
||||||
AND g.bigBlind in <limit_test>
|
<limit_test>
|
||||||
AND hp.tourneysPlayersId IS NULL
|
AND hp.tourneysPlayersId IS NULL
|
||||||
GROUP BY h.handStart, hp.handId, hp.totalProfit
|
GROUP BY h.handStart, hp.handId, hp.totalProfit
|
||||||
ORDER BY h.handStart"""
|
ORDER BY h.handStart"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user