render_to stats improved html def improved request date today dates st

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@render_to('stats/improved.html')
def improved(request):
d = date.today()
dates = [str(d - timedelta(i*7)) for i in xrange(9)]
q = Stat.all().filter('date', d - timedelta(1))
def value(q):
try:
return q.get().value
except AttributeError:
return 0
counts = {
'users': value(q.filter('type', Stat.TOTALUSERS)),
'questions': value(q.filter('type', Stat.TOTALQUESTIONS)),
}