Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated datetime stats, generated an index for odering, and stripping…

… the 'path' of the stats and values if present.
  • Loading branch information...
commit 1792fcaa589a3b09eb55c27aa6670cbeea26a4f2 1 parent 3878a4b
@ibolmo authored
Showing with 23 additions and 13 deletions.
  1. +8 −0 index.yaml
  2. +9 −7 measure.py
  3. +6 −6 myapp/stat.py
View
8 index.yaml
@@ -1,3 +1,11 @@
+indexes:
+- kind: Storage
+ properties:
+ - name: campaign
+ - name: namespace
+ - name: created_on
+ direction: desc
+
# AUTOGENERATED
# This index.yaml is automatically updated whenever the dev_appserver
View
16 measure.py
@@ -24,16 +24,18 @@ def get(self, key, path, format):
return self.error(404)
self.format = format or self.request.get('format', 'json')
- self.namespace, path = util.getParts((path or '').strip('/').replace('/', '.'))
+ self.namespace, self.path = util.getParts((path or '').strip('/').replace('/', '.'))
- logging.debug("%s, %s, %s; %s" % (key, self.namespace, self.format, path))
+ logging.debug("%s, %s, %s; %s" % (key, self.namespace, self.path, self.format))
helper = renderer.get(self.format)
- if path.startswith('values'): # this could be automated
- return helper.render_values(self, path)
- elif path.startswith('stats'):
- return helper.render_stats(self, path)
+ if self.path.startswith('values'): # this could be automated
+ self.path = self.path.lstrip('values').strip('.')
+ return helper.render_values(self)
+ elif self.path.startswith('stats'):
+ self.path = self.path.lstrip('stats').strip('.')
+ return helper.render_stats(self)
helper.render(self)
-
+
def post(self, key, path, format):
if (not key):
return self.error(500)
View
12 myapp/stat.py
@@ -172,12 +172,12 @@ def calculate(cls, datum):
NoSummary.calculate(datum) # No need for hits histogram
timetuple = datum.datetime.timetuple()
- for i, bucket in enumerate(['year%s', 'month%s', 'day%s', 'hour%s', 'minute%s', 'second%s', 'weekday%s', 'day%s_of_the_year']):
- if (cls.tally(stats = datum.stats, name = bucket % 's', index = timetuple[i]) is False):
- break
- cls.tally(stats = datum.stats, name = 'weekday.hour', index = '%s.%s' % (timetuple[-2], timetuple[3]))
- cls.tally(stats = datum.stats, name = 'month.day', index = '%s.%s' % (timetuple[1], timetuple[2]))
- cls.tally(stats = datum.stats, name = 'month.weekday', index = '%s.%s' % (timetuple[1], timetuple[-2]))
+ for i, bucket in enumerate(['year%s', 'month%s', 'day%s', 'hour%s', 'minute%s', 'second%s', 'weekday%s', 'day%sth']):
+ cls.tally(stats = datum.stats, name = bucket % 's', index = timetuple[i])
+ cls.tally(stats = datum.stats, name = 'weekdayth', index = datum.datetime.strftime('%U'))
+ cls.tally(stats = datum.stats, name = 'hour.weekday', index = '%s.%s' % (timetuple[3], timetuple[-2]))
+ cls.tally(stats = datum.stats, name = 'day.hour', index = '%s.%s' % (timetuple[2], timetuple[3]))
+ cls.tally(stats = datum.stats, name = 'weekday.month', index = '%s.%s' % (timetuple[-2], timetuple[1]))
'''
### Location
Please sign in to comment.
Something went wrong with that request. Please try again.