Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Limited the number of results shown on the stats dashboard.

  • Loading branch information...
commit 3002f097be8a6717fdef36cd0486ba7dd3dea001 1 parent 4bdbaa8
Paddy paddyforan authored
Showing with 70 additions and 49 deletions.
  1. +19 −5 devlinks.py
  2. +51 −44 index.yaml
24 devlinks.py
View
@@ -253,16 +253,30 @@ def get(self):
name="Web").save()
channel = channels.Channel(device.address, override_quota=True)
path = os.path.join(os.path.dirname(__file__), 'dashboard.html')
- stats_data = models.StatsData.all().order("-date").fetch(1000)
+ daily_stats_data = models.StatsData.all().filter('duration =',
+ 'day').order("-date").fetch(270)
+ hourly_stats_data = models.StatsData.all().filter('duration =',
+ 'hour').order('-date').fetch(216)
template_values = {
'channel_id': channel.token,
'stats': {'hour': {}, 'day': {}}
}
stats = template_values['stats']
- for datapoint in stats_data:
- if not (datapoint.datapoint in stats[datapoint.duration]):
- stats[datapoint.duration][datapoint.datapoint] = []
- stats[datapoint.duration][datapoint.datapoint].append({
+ for datapoint in daily_stats_data:
+ if not datapoint.datapoint in stats['day']:
+ stats['day'][datapoint.datapoint] = []
+ stats['day'][datapoint.datapoint].append({
+ 'name': datapoint.datapoint,
+ 'date': datapoint.date.strftime("%A %B %d, %Y"),
+ 'timestamp': int(time.mktime(
+ datapoint.date.timetuple()) * 1000),
+ 'count': int(datapoint.count),
+ 'duration': datapoint.duration
+ })
+ for datapoint in hourly_stats_data:
+ if not (datapoint.datapoint in stats['hour']):
+ stats['hour'][datapoint.datapoint] = []
+ stats['hour'][datapoint.datapoint].append({
'name': datapoint.datapoint,
'date': datapoint.date.strftime("%A %B %d, %Y at %H:%M"),
'timestamp': int(time.mktime(
95 index.yaml
View
@@ -1,44 +1,51 @@
-indexes:
-- kind: LinkData
- properties:
- - name: receiver
- - name: date
- direction: desc
-
-- kind: DeviceData
- properties:
- - name: user
- - name: default
-
-- kind: LinkData
- properties:
- - name: receiver
- - name: date
-
-- kind: LinkData
- properties:
- - name: received
- - name: receiver
- - name: date
- direction: desc
-
-- kind: StatsData
- properties:
- - name: datapoint
- - name: date
-
-# AUTOGENERATED
-
-# This index.yaml is automatically updated whenever the dev_appserver
-# detects that a new type of query is run. If you want to manage the
-# index.yaml file manually, remove the above marker line (the line
-# saying "# AUTOGENERATED"). If you want to manage some indexes
-# manually, move them above the marker line. The index.yaml file is
-# automatically uploaded to the admin console when you next deploy
-# your application using appcfg.py.
-
-- kind: Link
- properties:
- - name: author
- - name: date
- direction: desc
+indexes:
+- kind: LinkData
+ properties:
+ - name: receiver
+ - name: date
+ direction: desc
+
+- kind: DeviceData
+ properties:
+ - name: user
+ - name: default
+
+- kind: LinkData
+ properties:
+ - name: receiver
+ - name: date
+
+- kind: LinkData
+ properties:
+ - name: received
+ - name: receiver
+ - name: date
+ direction: desc
+
+- kind: StatsData
+ properties:
+ - name: datapoint
+ - name: date
+
+- kind: StatsData
+ properties:
+ - name: duration
+ - name: date
+ direction: desc
+
+
+# AUTOGENERATED
+
+# This index.yaml is automatically updated whenever the dev_appserver
+# detects that a new type of query is run. If you want to manage the
+# index.yaml file manually, remove the above marker line (the line
+# saying "# AUTOGENERATED"). If you want to manage some indexes
+# manually, move them above the marker line. The index.yaml file is
+# automatically uploaded to the admin console when you next deploy
+# your application using appcfg.py.
+
+- kind: Link
+ properties:
+ - name: author
+ - name: date
+ direction: desc
Please sign in to comment.
Something went wrong with that request. Please try again.