Skip to content
Browse files

Stats tweeks & smaller BG

  • Loading branch information...
1 parent f4d5445 commit ebc47a0cd707cdada130d37510837457105c8a61 @dustball dustball committed Jan 23, 2012
Showing with 28 additions and 2 deletions.
  1. +28 −2 main.py
  2. BIN static/bg.jpg
View
30 main.py
@@ -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)
View
BIN 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.
Something went wrong with that request. Please try again.