Skip to content

Commit

Permalink
Stats tweeks & smaller BG
Browse files Browse the repository at this point in the history
  • Loading branch information
dustball committed Jan 23, 2012
1 parent f4d5445 commit ebc47a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions main.py
Expand Up @@ -90,16 +90,42 @@ def to_dict(data):
metric=data.metric,
grade=data.grade,
who=m.hexdigest()[0:10],
month=datetime.now().strftime("%Y-%m"),
exact_time=datetime.now().strftime("%m-%d-%Y %H:%M:%S"),)
month=data.when.strftime("%Y-%m"),
exact_time=data.when.strftime("%m-%d-%Y %H:%M:%S"),)

self.response.out.write(simplejson.dumps([to_dict(data) for data in SatisfactionMetric.all()]))

# How many people answered each month
#
# Sample:
#
# {"2012-01": 12}

class BasicDataHandler(webapp.RequestHandler):
def get(self):

monthly_count = {}
monthly_users = {}

for sm in SatisfactionMetric.all():
month = sm.when.strftime("%Y-%m")
user = sm.who.email()
if month in monthly_count:
if user not in monthly_users[month]:
monthly_count[month] += 1
monthly_users[month][user] = 1
else:
monthly_count[month] = 0
monthly_users[month] = {}

self.response.out.write(simplejson.dumps(monthly_count))


def main():
application = webapp.WSGIApplication([
('/', MainHandler),
('/api/all', AllDataHandler),
('/api/basic', BasicDataHandler),
],debug=True)
util.run_wsgi_app(application)

Expand Down
Binary file modified static/bg.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ebc47a0

Please sign in to comment.