From 174aa4adfb2fa0faf1eb68c686a9f906326e183b Mon Sep 17 00:00:00 2001 From: steffen123 Date: Wed, 11 Aug 2010 00:10:10 +0200 Subject: [PATCH] hudcache is regenerated properly on mysql now --- pyfpdb/Database.py | 29 ++++++++++++++++++++++++----- pyfpdb/SQL.py | 8 ++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index de60384d..ed4d69c7 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1451,13 +1451,32 @@ class Database: + " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \ + " and h.startTime > '" + h_start + "'))" \ + " AND hp.tourneysPlayersId IS NULL)" - rebuild_sql_cash = self.sql.query['rebuildHudCache'].replace('', where) - print "rebuild_sql_cash:",rebuild_sql_cash - + rebuild_sql_cash = self.sql.query['rebuildHudCache'].replace('', "") + rebuild_sql_cash = rebuild_sql_cash.replace('', "") + rebuild_sql_cash = rebuild_sql_cash.replace('', "") + rebuild_sql_cash = rebuild_sql_cash.replace('', "") + rebuild_sql_cash = rebuild_sql_cash.replace('', where) + #print "rebuild_sql_cash:",rebuild_sql_cash self.get_cursor().execute(self.sql.query['clearHudCache']) - self.get_cursor().execute(rebuild_sql_cash) - #self.get_cursor().execute(rebuild_sql_tour) + + if self.hero_ids == {}: + where = "WHERE hp.tourneysPlayersId >= 0" + else: + where = "where ((( hp.playerId not in " + str(tuple(self.hero_ids.values())) \ + + " and h.startTime > '" + v_start + "')" \ + + " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \ + + " and h.startTime > '" + h_start + "'))" \ + + " AND hp.tourneysPlayersId >= 0)" + rebuild_sql_tourney = self.sql.query['rebuildHudCache'].replace('', ",tourneyTypeId") + rebuild_sql_tourney = rebuild_sql_tourney.replace('', ",t.tourneyTypeId") + rebuild_sql_tourney = rebuild_sql_tourney.replace('', """INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId) + INNER JOIN Tourneys t ON (t.id = tp.tourneyId)""") + rebuild_sql_tourney = rebuild_sql_tourney.replace('', ",t.tourneyTypeId") + rebuild_sql_tourney = rebuild_sql_tourney.replace('', where) + #print "rebuild_sql_tourney:",rebuild_sql_tourney + + self.get_cursor().execute(rebuild_sql_tourney) self.commit() print "Rebuild hudcache took %.1f seconds" % (time() - stime,) except: diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 194826bf..5c4b8cf3 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2990,6 +2990,7 @@ class Sql: ,playerId ,activeSeats ,position + ,styleKey ,HDs ,wonWhenSeenStreet1 @@ -3079,6 +3080,7 @@ class Sql: when hp.position = '9' then 'E' else 'E' end AS hc_position + ,date_format(h.startTime, 'd%y%m%d') ,count(1) ,sum(wonWhenSeenStreet1) @@ -3152,11 +3154,13 @@ class Sql: ,sum(hp.street4Raises) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) + GROUP BY h.gametypeId ,hp.playerId ,h.seats ,hc_position + ,date_format(h.startTime, 'd%y%m%d') """ elif db_server == 'postgresql': @@ -3342,6 +3346,7 @@ class Sql: ,playerId ,activeSeats ,position + ,styleKey ,HDs ,wonWhenSeenStreet1 @@ -3431,6 +3436,7 @@ class Sql: when hp.position = '9' then 'E' else 'E' end AS hc_position + ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) ,count(1) ,sum(wonWhenSeenStreet1) @@ -3504,11 +3510,13 @@ class Sql: ,sum(CAST(hp.street4Raises as integer)) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) + GROUP BY h.gametypeId ,hp.playerId ,h.seats ,hc_position + ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) """