From 115c44e7b1ed31d079e0043621a49ff9dd2a6bac Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 26 Oct 2009 16:39:37 +0800 Subject: [PATCH] Move session stats query into SQL.py --- pyfpdb/GuiSessionViewer.py | 17 ++--------------- pyfpdb/SQL.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/pyfpdb/GuiSessionViewer.py b/pyfpdb/GuiSessionViewer.py index 140a134e..2013f8a2 100755 --- a/pyfpdb/GuiSessionViewer.py +++ b/pyfpdb/GuiSessionViewer.py @@ -235,22 +235,9 @@ class GuiSessionViewer (threading.Thread): def generateDatasets(self, playerids, sitenos, limits, seats): # Get a list of all handids and their timestampts - # FIXME: Will probably want to be able to filter this list eventually - # FIXME: Join on handsplayers for Hero to get other useful stuff like total profit? + #FIXME: Query still need to filter on blind levels - - # Postgres version requires - EXTRACT(epoch from h.handStart) - q = """ -select UNIX_TIMESTAMP(h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit -from HandsPlayers hp - inner join Hands h on (h.id = hp.handId) - inner join Gametypes gt on (gt.Id = h.gameTypeId) - inner join Sites s on (s.Id = gt.siteId) - inner join Players p on (p.Id = hp.playerId) -where hp.playerId in -and date_format(h.handStart, '%Y-%m-%d') -order by time -""" + q = self.sql.query['sessionStats'] start_date, end_date = self.filters.getDates() q = q.replace("", " between '" + start_date + "' and '" + end_date + "'") diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 251a56fa..13f592cd 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2475,6 +2475,33 @@ class Sql: GROUP BY h.handStart, hp.handId, hp.totalProfit ORDER BY h.handStart""" + #################################### + # Session stats query + #################################### + if db_server == 'mysql': + self.query['sessionStats'] = """ + SELECT UNIX_TIMESTAMP(h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit + FROM HandsPlayers hp + INNER JOIN Hands h on (h.id = hp.handId) + INNER JOIN Gametypes gt on (gt.Id = h.gameTypeId) + INNER JOIN Sites s on (s.Id = gt.siteId) + INNER JOIN Players p on (p.Id = hp.playerId) + WHERE hp.playerId in + AND date_format(h.handStart, '%Y-%m-%d') + ORDER by time""" + elif db_server == 'postgresql': + self.query['sessionStats'] = """ + SELECT EXTRACT(epoch from h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit + FROM HandsPlayers hp + INNER JOIN Hands h on (h.id = hp.handId) + INNER JOIN Gametypes gt on (gt.Id = h.gameTypeId) + INNER JOIN Sites s on (s.Id = gt.siteId) + INNER JOIN Players p on (p.Id = hp.playerId) + WHERE hp.playerId in + AND date_format(h.handStart, '%Y-%m-%d') + ORDER by time""" + elif db_server == 'sqlite': + self.query['sessionStats'] = """ """ #################################### # Queries to rebuild/modify hudcache