diff --git a/tipbot.py b/tipbot.py index cacb105..0a25ed1 100644 --- a/tipbot.py +++ b/tipbot.py @@ -339,6 +339,19 @@ def MigrateRedis(): redisdb.hset(hname,newkey,redisdb.hget(hname,key)) redisdb.hdel(hname,key) + keys=redisdb.keys('*') + for key in keys: + if key.find(":zstats:") >= 0 and key.find(":freenode:") < 0: + altkey=key.replace(":zstats:",":zstats:freenode:") + if not redisdb.exists(altkey): + log_info('copying %s to %s' % (key,altkey)) + redisdb.restore(altkey,0,redisdb.dump(key)) + elif key.endswith(":stats:"): + altkey=key.replace(":stats:",":stats:freenode:") + if not redisdb.exists(altkey): + log_info('copying %s to %s' % (key,altkey)) + redisdb.restore(altkey,0,redisdb.dump(key)) + RegisterCommands() redisdb = connect_to_redis(config.redis_host,config.redis_port) MigrateRedis() diff --git a/tipbot/betutils.py b/tipbot/betutils.py index 5b04e84..829c3b7 100644 --- a/tipbot/betutils.py +++ b/tipbot/betutils.py @@ -146,42 +146,63 @@ def RecordGameResult(link,game,win,lose,units): tname="%s:stats:"%game+identity rtname="%s:stats:reset:"%game+identity alltname="%s:stats:"%game + nalltname="%s:stats:"%game zhtname="%s:zstats:hourly:"%game zdtname="%s:zstats:daily:"%game + nzhtname="%s:zstats:%s:hourly:"%(game,link.network.name) + nzdtname="%s:zstats:%s:daily:"%(game,link.network.name) p.hincrby(tname,"bets",1) p.hincrby(rtname,"bets",1) p.hincrby(alltname,"bets",1) + p.hincrby(nalltname,"bets",1) p.zincrby(zhtname+"bets",tsh,1) p.zincrby(zdtname+"bets",tsd,1) + p.zincrby(nzhtname+"bets",tsh,1) + p.zincrby(nzdtname+"bets",tsd,1) p.hincrby(tname,"wagered",units) p.hincrby(rtname,"wagered",units) p.hincrby(alltname,"wagered",units) + p.hincrby(nalltname,"wagered",units) p.zincrby(zhtname+"wagered",tsh,units) p.zincrby(zdtname+"wagered",tsd,units) + p.zincrby(nzhtname+"wagered",tsh,units) + p.zincrby(nzdtname+"wagered",tsd,units) if win: p.hincrby("balances",identity,units) p.hincrby(tname,"won",units) p.hincrby(rtname,"won",units) p.hincrby(alltname,"won",units) + p.hincrby(nalltname,"won",units) p.zincrby(zhtname+"won",tsh,units) p.zincrby(zdtname+"won",tsd,units) + p.zincrby(nzhtname+"won",tsh,units) + p.zincrby(nzdtname+"won",tsd,units) p.hincrby(tname,"nwon",1) p.hincrby(rtname,"nwon",1) p.hincrby(alltname,"nwon",1) + p.hincrby(nalltname,"nwon",1) p.zincrby(zhtname+"nwon",tsh,1) p.zincrby(zdtname+"nwon",tsd,1) + p.zincrby(nzhtname+"nwon",tsh,1) + p.zincrby(nzdtname+"nwon",tsd,1) if lose: p.hincrby("balances",identity,-units) p.hincrby(tname,"lost",units) p.hincrby(rtname,"lost",units) p.hincrby(alltname,"lost",units) + p.hincrby(nalltname,"lost",units) p.zincrby(zhtname+"lost",tsh,units) p.zincrby(zdtname+"lost",tsd,units) + p.zincrby(nzhtname+"lost",tsh,units) + p.zincrby(nzdtname+"lost",tsd,units) p.hincrby(tname,"nlost",1) p.hincrby(rtname,"nlost",1) p.hincrby(alltname,"nlost",1) + p.hincrby(nalltname,"nlost",1) p.zincrby(zhtname+"nlost",tsh,1) p.zincrby(zdtname+"nlost",tsd,1) + p.zincrby(nzhtname+"nlost",tsh,1) + p.zincrby(nzdtname+"nlost",tsd,1) p.execute() except Exception,e: log_error('RecordGameResult: exception updating redis: %s' % str(e))