Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: appengine/chromium_cq_status/handlers/stats_viewer.py

Issue 2111713004: Teach CQ status app to check login status of users. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: cleanup Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import webapp2 5 import webapp2
6 6
7 from shared.utils import minutes_per_day 7 from shared.utils import minutes_per_day, read_access
Sergiy Byelozyorov 2016/07/01 17:13:06 for consistency with other files, please rewrite a
tandrii(chromium) 2016/07/01 18:56:55 Done.
8 8
9 period_config = { 9 period_config = {
10 '15-minutely': { 10 '15-minutely': {
11 'interval_minutes': 15, 11 'interval_minutes': 15,
12 'window_length': minutes_per_day / 15, 12 'window_length': minutes_per_day / 15,
13 'data_points': 2 * minutes_per_day / 15, 13 'data_points': 2 * minutes_per_day / 15,
14 }, 14 },
15 'hourly': { 15 'hourly': {
16 'interval_minutes': 60, 16 'interval_minutes': 60,
17 'window_length': 48, 17 'window_length': 48,
18 'data_points': 7 * 24, 18 'data_points': 7 * 24,
19 }, 19 },
20 'daily': { 20 'daily': {
21 'interval_minutes': minutes_per_day, 21 'interval_minutes': minutes_per_day,
22 'window_length': 14, 22 'window_length': 14,
23 'data_points': 4 * 30, 23 'data_points': 4 * 30,
24 }, 24 },
25 'weekly': { 25 'weekly': {
26 'interval_minutes': 7 * minutes_per_day, 26 'interval_minutes': 7 * minutes_per_day,
27 'window_length': 4, 27 'window_length': 4,
28 'data_points': 104, 28 'data_points': 104,
29 }, 29 },
30 } 30 }
31 31
32 class StatsViewer(webapp2.RequestHandler): # pragma: no cover 32 class StatsViewer(webapp2.RequestHandler): # pragma: no cover
33 @read_access
33 def get(self, project, period): 34 def get(self, project, period):
34 assert period in period_config 35 assert period in period_config
35 config = period_config[period] 36 config = period_config[period]
36 data_points = self.request.get('data_points') or config['data_points'] 37 data_points = self.request.get('data_points') or config['data_points']
37 self.response.write(open('templates/stats_viewer.html').read() % { 38 self.response.write(open('templates/stats_viewer.html').read() % {
38 'project': project, 39 'project': project,
39 'period': period, 40 'period': period,
40 'interval_minutes': config['interval_minutes'], 41 'interval_minutes': config['interval_minutes'],
41 'window_length': config['window_length'], 42 'window_length': config['window_length'],
42 'data_points': data_points, 43 'data_points': data_points,
43 }) 44 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698