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 logging | 5 import logging |
6 import traceback | 6 import traceback |
7 | 7 |
8 from google.appengine.api import memcache | 8 from google.appengine.api import memcache |
9 from google.appengine.datastore.datastore_query import Cursor | 9 from google.appengine.datastore.datastore_query import Cursor |
10 import webapp2 | 10 import webapp2 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ensure_last_change_timestamp(interval_minutes) | 84 ensure_last_change_timestamp(interval_minutes) |
85 | 85 |
86 return { | 86 return { |
87 'results': [stats.to_dict(names) for stats in stats_list], | 87 'results': [stats.to_dict(names) for stats in stats_list], |
88 'cursor': next_cursor, | 88 'cursor': next_cursor, |
89 'more': more, | 89 'more': more, |
90 } | 90 } |
91 | 91 |
92 class StatsQuery(webapp2.RequestHandler): | 92 class StatsQuery(webapp2.RequestHandler): |
93 @utils.cross_origin_json | 93 @utils.cross_origin_json |
| 94 @utils.read_access |
94 def get(self): | 95 def get(self): |
95 try: | 96 try: |
96 params = parse_request(self.request, { | 97 params = parse_request(self.request, { |
97 'key': parse_cqstats_key, | 98 'key': parse_cqstats_key, |
98 'project': parse_string, | 99 'project': parse_string, |
99 'interval_minutes': use_default(parse_non_negative_integer, None), | 100 'interval_minutes': use_default(parse_non_negative_integer, None), |
100 'begin': parse_timestamp, | 101 'begin': parse_timestamp, |
101 'end': parse_timestamp, | 102 'end': parse_timestamp, |
102 'names': parse_strings, | 103 'names': parse_strings, |
103 'count': parse_query_count, | 104 'count': parse_query_count, |
104 'cursor': parse_cursor, | 105 'cursor': parse_cursor, |
105 }) | 106 }) |
106 return execute_query(**params) | 107 return execute_query(**params) |
107 except ValueError as e: # pragma: no cover | 108 except ValueError as e: # pragma: no cover |
108 logging.warning(traceback.format_exc()) | 109 logging.warning(traceback.format_exc()) |
109 self.response.write(e) | 110 self.response.write(e) |
OLD | NEW |