mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Time based stats are now daily and (all time) hourly
Cuts down on unnecessary detail/storage
This commit is contained in:
parent
5d56c82cad
commit
866c1f485c
1 changed files with 16 additions and 8 deletions
|
@ -116,40 +116,48 @@ def RecordGameResult(link,game,win,lose,units):
|
||||||
identity=link.identity()
|
identity=link.identity()
|
||||||
try:
|
try:
|
||||||
ts=datetime.datetime.utcnow()
|
ts=datetime.datetime.utcnow()
|
||||||
ts="%u-%02u-%02u-%02u" % (ts.year,ts.month,ts.day,ts.hour)
|
tsh="%u" % (ts.hour)
|
||||||
|
tsd="%u-%02u-%02u" % (ts.year,ts.month,ts.day)
|
||||||
p = redis_pipeline()
|
p = redis_pipeline()
|
||||||
tname="%s:stats:"%game+identity
|
tname="%s:stats:"%game+identity
|
||||||
rtname="%s:stats:reset:"%game+identity
|
rtname="%s:stats:reset:"%game+identity
|
||||||
alltname="%s:stats:"%game
|
alltname="%s:stats:"%game
|
||||||
ztname="%s:zstats:"%game+":"
|
zhtname="%s:zstats:hourly:"%game
|
||||||
|
zdtname="%s:zstats:daily:"%game
|
||||||
p.hincrby(tname,"bets",1)
|
p.hincrby(tname,"bets",1)
|
||||||
p.hincrby(rtname,"bets",1)
|
p.hincrby(rtname,"bets",1)
|
||||||
p.hincrby(alltname,"bets",1)
|
p.hincrby(alltname,"bets",1)
|
||||||
p.zincrby(ztname+"bets",ts,1)
|
p.zincrby(zhtname+"bets",tsh,1)
|
||||||
|
p.zincrby(zdtname+"bets",tsd,1)
|
||||||
p.hincrby(tname,"wagered",units)
|
p.hincrby(tname,"wagered",units)
|
||||||
p.hincrby(rtname,"wagered",units)
|
p.hincrby(rtname,"wagered",units)
|
||||||
p.hincrby(alltname,"wagered",units)
|
p.hincrby(alltname,"wagered",units)
|
||||||
p.zincrby(ztname+"wagered",ts,units)
|
p.zincrby(zhtname+"wagered",tsh,units)
|
||||||
|
p.zincrby(zdtname+"wagered",tsd,units)
|
||||||
if win:
|
if win:
|
||||||
p.hincrby("balances",identity,units)
|
p.hincrby("balances",identity,units)
|
||||||
p.hincrby(tname,"won",units)
|
p.hincrby(tname,"won",units)
|
||||||
p.hincrby(rtname,"won",units)
|
p.hincrby(rtname,"won",units)
|
||||||
p.hincrby(alltname,"won",units)
|
p.hincrby(alltname,"won",units)
|
||||||
p.zincrby(ztname+"won",ts,units)
|
p.zincrby(zhtname+"won",tsh,units)
|
||||||
|
p.zincrby(zdtname+"won",tsd,units)
|
||||||
p.hincrby(tname,"nwon",1)
|
p.hincrby(tname,"nwon",1)
|
||||||
p.hincrby(rtname,"nwon",1)
|
p.hincrby(rtname,"nwon",1)
|
||||||
p.hincrby(alltname,"nwon",1)
|
p.hincrby(alltname,"nwon",1)
|
||||||
p.zincrby(ztname+"nwon",ts,1)
|
p.zincrby(zhtname+"nwon",tsh,1)
|
||||||
|
p.zincrby(zdtname+"nwon",tsd,1)
|
||||||
if lose:
|
if lose:
|
||||||
p.hincrby("balances",identity,-units)
|
p.hincrby("balances",identity,-units)
|
||||||
p.hincrby(tname,"lost",units)
|
p.hincrby(tname,"lost",units)
|
||||||
p.hincrby(rtname,"lost",units)
|
p.hincrby(rtname,"lost",units)
|
||||||
p.hincrby(alltname,"lost",units)
|
p.hincrby(alltname,"lost",units)
|
||||||
p.zincrby(ztname+"lost",ts,units)
|
p.zincrby(zhtname+"lost",tsh,units)
|
||||||
|
p.zincrby(zdtname+"lost",tsd,units)
|
||||||
p.hincrby(tname,"nlost",1)
|
p.hincrby(tname,"nlost",1)
|
||||||
p.hincrby(rtname,"nlost",1)
|
p.hincrby(rtname,"nlost",1)
|
||||||
p.hincrby(alltname,"nlost",1)
|
p.hincrby(alltname,"nlost",1)
|
||||||
p.zincrby(ztname+"nlost",ts,1)
|
p.zincrby(zhtname+"nlost",tsh,1)
|
||||||
|
p.zincrby(zdtname+"nlost",tsd,1)
|
||||||
p.execute()
|
p.execute()
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
log_error('RecordGameResult: exception updating redis: %s' % str(e))
|
log_error('RecordGameResult: exception updating redis: %s' % str(e))
|
||||||
|
|
Loading…
Reference in a new issue