get hudcache update to work for sqlite - hud now working!

This commit is contained in:
sqlcoder 2009-08-07 00:04:44 +01:00
parent c0ddaad2e5
commit 126dfd7331
2 changed files with 20 additions and 10 deletions

View File

@ -971,12 +971,14 @@ class Database:
try: try:
stime = time() stime = time()
self.connection.cursor().execute(self.sql.query['clearHudCache']) self.get_cursor().execute(self.sql.query['clearHudCache'])
self.connection.cursor().execute(self.sql.query['rebuildHudCache']) self.get_cursor().execute(self.sql.query['rebuildHudCache'])
self.commit() self.commit()
print "Rebuild hudcache took %.1f seconds" % (time() - stime,) print "Rebuild hudcache took %.1f seconds" % (time() - stime,)
except: except:
err = traceback.extract_tb(sys.exc_info()[2])[-1]
print "Error rebuilding hudcache:", str(sys.exc_value) print "Error rebuilding hudcache:", str(sys.exc_value)
print err
#end def rebuild_hudcache #end def rebuild_hudcache
@ -1616,11 +1618,14 @@ class Database:
row[56], row[57], row[58], row[59], row[60], row[56], row[57], row[58], row[59], row[60],
row[1], row[2], row[3], str(row[4]), row[5], styleKey)) row[1], row[2], row[3], str(row[4]), row[5], styleKey))
# Test statusmessage to see if update worked, do insert if not # Test statusmessage to see if update worked, do insert if not
#print "storehud2, upd num =", num #print "storehud2, upd num =", num.rowcount
# num is a cursor in sqlite
if ( (backend == self.PGSQL and cursor.statusmessage != "UPDATE 1") if ( (backend == self.PGSQL and cursor.statusmessage != "UPDATE 1")
or (backend == self.MYSQL_INNODB and num == 0) ): or (backend == self.MYSQL_INNODB and num == 0)
or (backend == self.SQLITE and num.rowcount == 0)
):
#print "playerid before insert:",row[2]," num = ", num #print "playerid before insert:",row[2]," num = ", num
cursor.execute("""INSERT INTO HudCache num = cursor.execute("""INSERT INTO HudCache
(gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey, (gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey,
HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone, HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown, street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
@ -1651,7 +1656,7 @@ class Database:
,row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40] ,row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40]
,row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50] ,row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50]
,row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60]) ) ,row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60]) )
#print "hopefully inserted hud data line: ", cursor.statusmessage #print "hopefully inserted hud data line: ", cursor.rowcount
# message seems to be "INSERT 0 1" # message seems to be "INSERT 0 1"
else: else:
#print "updated(2) hud data line" #print "updated(2) hud data line"

View File

@ -1667,6 +1667,11 @@ class Sql:
select coalesce(max(id),0) select coalesce(max(id),0)
from Hands from Hands
where handStart < now() at time zone 'UTC' - interval '1 day'""" where handStart < now() at time zone 'UTC' - interval '1 day'"""
elif db_server == 'sqlite':
self.query['get_hand_1day_ago'] = """
select coalesce(max(id),0)
from Hands
where handStart < strftime('%J', 'now') - 1"""
# not used yet ... # not used yet ...
# gets a date, would need to use handsplayers (not hudcache) to get exact hand Id # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id
@ -2105,7 +2110,7 @@ class Sql:
when stats.PlPosition = 1 then 'CO' when stats.PlPosition = 1 then 'CO'
when stats.PlPosition = 2 then 'MP' when stats.PlPosition = 2 then 'MP'
when stats.PlPosition = 5 then 'EP' when stats.PlPosition = 5 then 'EP'
else '??' else 'xx'
end AS PlPosition end AS PlPosition
,stats.n ,stats.n
,stats.vpip ,stats.vpip
@ -2239,7 +2244,7 @@ class Sql:
when stats.PlPosition = 1 then 'CO' when stats.PlPosition = 1 then 'CO'
when stats.PlPosition = 2 then 'MP' when stats.PlPosition = 2 then 'MP'
when stats.PlPosition = 5 then 'EP' when stats.PlPosition = 5 then 'EP'
else '??' else 'xx'
end AS PlPosition end AS PlPosition
,stats.n ,stats.n
,stats.vpip ,stats.vpip
@ -2767,7 +2772,7 @@ class Sql:
else 'E' else 'E'
end AS hc_position end AS hc_position
,hp.tourneyTypeId ,hp.tourneyTypeId
,'d' || substr(strftime('%Y%m%d', h.handStart),3) ,'d' || substr(strftime('%Y%m%d', h.handStart),3,7)
,count(1) ,count(1)
,sum(wonWhenSeenStreet1) ,sum(wonWhenSeenStreet1)
,sum(wonAtSD) ,sum(wonAtSD)
@ -2830,7 +2835,7 @@ class Sql:
,h.seats ,h.seats
,hc_position ,hc_position
,hp.tourneyTypeId ,hp.tourneyTypeId
,'d' || substr(strftime('%Y%m%d', h.handStart),3) ,'d' || substr(strftime('%Y%m%d', h.handStart),3,7)
""" """
if db_server == 'mysql': if db_server == 'mysql':