Move session stats query into SQL.py

This commit is contained in:
Worros 2009-10-26 16:39:37 +08:00
parent e0c193b77d
commit 115c44e7b1
2 changed files with 29 additions and 15 deletions

View File

@ -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 <player_test>
and date_format(h.handStart, '%Y-%m-%d') <datestest>
order by time
"""
q = self.sql.query['sessionStats']
start_date, end_date = self.filters.getDates()
q = q.replace("<datestest>", " between '" + start_date + "' and '" + end_date + "'")

View File

@ -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 <player_test>
AND date_format(h.handStart, '%Y-%m-%d') <datestest>
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 <player_test>
AND date_format(h.handStart, '%Y-%m-%d') <datestest>
ORDER by time"""
elif db_server == 'sqlite':
self.query['sessionStats'] = """ """
####################################
# Queries to rebuild/modify hudcache