Patch from sqlcoder to make the query for the profit graph smarter/faster

This commit is contained in:
Worros
2008-11-14 08:15:28 +10:00
parent c2475db712
commit 34e374a55e
2 changed files with 36 additions and 2 deletions
+8 -2
View File
@@ -20,6 +20,7 @@ import pygtk
pygtk.require('2.0')
import gtk
import os
from time import time
#import pokereval
try:
@@ -65,7 +66,9 @@ class GuiGraphViewer (threading.Thread):
self.ax = self.fig.add_subplot(111)
#Get graph data from DB
starttime = time()
line = self.getRingProfitGraph(name, site)
print "Graph generated in: %s" %(time() - starttime)
self.ax.set_title("Profit graph for ring games")
@@ -90,7 +93,9 @@ class GuiGraphViewer (threading.Thread):
#end of def showClicked
def getRingProfitGraph(self, name, site):
self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site))
#self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site))
self.cursor.execute(self.sql.query['getRingProfitAllHandsPlayerIdSite'], (name, site))
# returns (HandId,Winnings,Costs,Profit)
winnings = self.db.cursor.fetchall()
profit=range(len(winnings))
@@ -99,7 +104,8 @@ class GuiGraphViewer (threading.Thread):
spent = self.db.cursor.fetchone()
profit[i]=(i, winnings[i][1]-spent[0])
y=map(lambda x:float(x[1]), profit)
# y=map(lambda x:float(x[1]), profit)
y=map(lambda x:float(x[3]), winnings)
line = cumsum(y)
return line/100
#end of def getRingProfitGraph