Save stats/zstats per network

This commit is contained in:
moneromooo 2015-01-25 20:46:02 +00:00
parent fc45df4a8c
commit 69582695f6
2 changed files with 34 additions and 0 deletions

View file

@ -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))