From 6fa3d693d9d90b74501f45a5219fddae702a1d05 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Fri, 22 Jan 2010 18:36:21 +0100 Subject: [PATCH] game selector for graphs added. exception caught for games selector for player stats --- pyfpdb/GuiGraphViewer.py | 22 ++++++++++++++++++++-- pyfpdb/GuiPlayerStats.py | 13 ++++++++----- pyfpdb/SQL.py | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 9daa940f..0b2d20cd 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -137,6 +137,8 @@ class GuiGraphViewer (threading.Thread): heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() + games = self.filters.getGames() + for i in ('show', 'none'): if i in limits: limits.remove(i) @@ -171,7 +173,7 @@ class GuiGraphViewer (threading.Thread): #Get graph data from DB starttime = time() - (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits) + (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits, games) print "Graph generated in: %s" %(time() - starttime) self.ax.set_title("Profit graph for ring games") @@ -212,7 +214,7 @@ class GuiGraphViewer (threading.Thread): #end of def showClicked - def getRingProfitGraph(self, names, sites, limits): + def getRingProfitGraph(self, names, sites, limits, games): tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite'] # print "DEBUG: getRingProfitGraph" start_date, end_date = self.filters.getDates() @@ -224,6 +226,22 @@ class GuiGraphViewer (threading.Thread): sitetest = str(tuple(sites)) #nametest = nametest.replace("L", "") + q = [] + for m in self.filters.display.items(): + if m[0] == 'Games' and m[1]: + for n in games: + if games[n]: + q.append(n) + if len(q) > 0: + gametest = str(tuple(q)) + gametest = gametest.replace("L", "") + gametest = gametest.replace(",)",")") + gametest = gametest.replace("u'","'") + gametest = "and gt.category in %s" % gametest + else: + gametest = "and gt.category IS NULL" + tmp = tmp.replace("", gametest) + lims = [int(x) for x in limits if x.isdigit()] potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl'] nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl'] diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 1da08fbc..e842b301 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -474,11 +474,14 @@ class GuiPlayerStats (threading.Thread): for n in games: if games[n]: q.append(n) - gametest = str(tuple(q)) - gametest = gametest.replace("L", "") - gametest = gametest.replace(",)",")") - gametest = gametest.replace("u'","'") - gametest = "and gt.category in %s" % gametest + if len(q) > 0: + gametest = str(tuple(q)) + gametest = gametest.replace("L", "") + gametest = gametest.replace(",)",")") + gametest = gametest.replace("u'","'") + gametest = "and gt.category in %s" % gametest + else: + gametest = "and gt.category IS NULL" query = query.replace("", gametest) if seats: diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index c377c7b6..5913c624 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2576,6 +2576,7 @@ class Sql: AND h.handStart > '' AND h.handStart < '' + AND hp.tourneysPlayersId IS NULL GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit ORDER BY h.handStart"""