hudcache is regenerated properly on mysql now

This commit is contained in:
steffen123 2010-08-11 00:10:10 +02:00
parent 36b212388d
commit 174aa4adfb
2 changed files with 32 additions and 5 deletions

View File

@ -1451,13 +1451,32 @@ class Database:
+ " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \ + " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \
+ " and h.startTime > '" + h_start + "'))" \ + " and h.startTime > '" + h_start + "'))" \
+ " AND hp.tourneysPlayersId IS NULL)" + " AND hp.tourneysPlayersId IS NULL)"
rebuild_sql_cash = self.sql.query['rebuildHudCache'].replace('<where_clause>', where) rebuild_sql_cash = self.sql.query['rebuildHudCache'].replace('<tourney1_clause>', "")
print "rebuild_sql_cash:",rebuild_sql_cash rebuild_sql_cash = rebuild_sql_cash.replace('<tourney2_clause>', "")
rebuild_sql_cash = rebuild_sql_cash.replace('<tourney_join_clause>', "")
rebuild_sql_cash = rebuild_sql_cash.replace('<tourney_group_clause>', "")
rebuild_sql_cash = rebuild_sql_cash.replace('<where_clause>', where)
#print "rebuild_sql_cash:",rebuild_sql_cash
self.get_cursor().execute(self.sql.query['clearHudCache']) self.get_cursor().execute(self.sql.query['clearHudCache'])
self.get_cursor().execute(rebuild_sql_cash) 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('<tourney1_clause>', ",tourneyTypeId")
rebuild_sql_tourney = rebuild_sql_tourney.replace('<tourney2_clause>', ",t.tourneyTypeId")
rebuild_sql_tourney = rebuild_sql_tourney.replace('<tourney_join_clause>', """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('<tourney_group_clause>', ",t.tourneyTypeId")
rebuild_sql_tourney = rebuild_sql_tourney.replace('<where_clause>', where)
#print "rebuild_sql_tourney:",rebuild_sql_tourney
self.get_cursor().execute(rebuild_sql_tourney)
self.commit() self.commit()
print "Rebuild hudcache took %.1f seconds" % (time() - stime,) print "Rebuild hudcache took %.1f seconds" % (time() - stime,)
except: except:

View File

@ -2990,6 +2990,7 @@ class Sql:
,playerId ,playerId
,activeSeats ,activeSeats
,position ,position
<tourney1_clause>
,styleKey ,styleKey
,HDs ,HDs
,wonWhenSeenStreet1 ,wonWhenSeenStreet1
@ -3079,6 +3080,7 @@ class Sql:
when hp.position = '9' then 'E' when hp.position = '9' then 'E'
else 'E' else 'E'
end AS hc_position end AS hc_position
<tourney2_clause>
,date_format(h.startTime, 'd%y%m%d') ,date_format(h.startTime, 'd%y%m%d')
,count(1) ,count(1)
,sum(wonWhenSeenStreet1) ,sum(wonWhenSeenStreet1)
@ -3152,11 +3154,13 @@ class Sql:
,sum(hp.street4Raises) ,sum(hp.street4Raises)
FROM HandsPlayers hp FROM HandsPlayers hp
INNER JOIN Hands h ON (h.id = hp.handId) INNER JOIN Hands h ON (h.id = hp.handId)
<tourney_join_clause>
<where_clause> <where_clause>
GROUP BY h.gametypeId GROUP BY h.gametypeId
,hp.playerId ,hp.playerId
,h.seats ,h.seats
,hc_position ,hc_position
<tourney_group_clause>
,date_format(h.startTime, 'd%y%m%d') ,date_format(h.startTime, 'd%y%m%d')
""" """
elif db_server == 'postgresql': elif db_server == 'postgresql':
@ -3342,6 +3346,7 @@ class Sql:
,playerId ,playerId
,activeSeats ,activeSeats
,position ,position
<tourney1_clause>
,styleKey ,styleKey
,HDs ,HDs
,wonWhenSeenStreet1 ,wonWhenSeenStreet1
@ -3431,6 +3436,7 @@ class Sql:
when hp.position = '9' then 'E' when hp.position = '9' then 'E'
else 'E' else 'E'
end AS hc_position end AS hc_position
<tourney2_clause>
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
,count(1) ,count(1)
,sum(wonWhenSeenStreet1) ,sum(wonWhenSeenStreet1)
@ -3504,11 +3510,13 @@ class Sql:
,sum(CAST(hp.street4Raises as integer)) ,sum(CAST(hp.street4Raises as integer))
FROM HandsPlayers hp FROM HandsPlayers hp
INNER JOIN Hands h ON (h.id = hp.handId) INNER JOIN Hands h ON (h.id = hp.handId)
<tourney_join_clause>
<where_clause> <where_clause>
GROUP BY h.gametypeId GROUP BY h.gametypeId
,hp.playerId ,hp.playerId
,h.seats ,h.seats
,hc_position ,hc_position
<tourney_group_clause>
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
""" """