OLD | NEW |
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 model.cq_stats import CQStats | 7 from model.cq_stats import CQStats |
8 from shared.utils import cross_origin_json | 8 from shared import utils |
| 9 |
9 | 10 |
10 class StatsDataPoints(webapp2.RequestHandler): | 11 class StatsDataPoints(webapp2.RequestHandler): |
11 @cross_origin_json | 12 @utils.cross_origin_json |
| 13 @utils.read_access |
12 def get(self, ranking, name, cq_stats_key): # pylint: disable=R0201 | 14 def get(self, ranking, name, cq_stats_key): # pylint: disable=R0201 |
13 cq_stats = CQStats.get_by_id(int(cq_stats_key)) | 15 cq_stats = CQStats.get_by_id(int(cq_stats_key)) |
14 assert cq_stats, '%s must match a CQStats entry.' % cq_stats_key | 16 assert cq_stats, '%s must match a CQStats entry.' % cq_stats_key |
15 for stats in cq_stats.count_stats + cq_stats.list_stats: | 17 for stats in cq_stats.count_stats + cq_stats.list_stats: |
16 if stats.name == name: | 18 if stats.name == name: |
17 if ranking == 'lowest': | 19 if ranking == 'lowest': |
18 return stats.lowest_100 | 20 return stats.lowest_100 |
19 assert ranking == 'highest' | 21 assert ranking == 'highest' |
20 return stats.highest_100 | 22 return stats.highest_100 |
21 assert False, '%s must match a stat in the specified CQStats entry.' % name | 23 assert False, '%s must match a stat in the specified CQStats entry.' % name |
OLD | NEW |