| 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 from google.appengine.datastore.datastore_query import Cursor | 5 from google.appengine.datastore.datastore_query import Cursor |
| 6 from google.appengine.ext import ndb | 6 from google.appengine.ext import ndb |
| 7 from google.appengine.ext.webapp import template | 7 from google.appengine.ext.webapp import template |
| 8 | 8 |
| 9 from model.flake import Flake | 9 from model.flake import Flake |
| 10 from status.cq_status import is_last_hour | 10 from status.cq_status import is_last_hour |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 patchsets = ndb.get_multi(patchsets_keys) | 34 patchsets = ndb.get_multi(patchsets_keys) |
| 35 | 35 |
| 36 filtered_occurrences = [] | 36 filtered_occurrences = [] |
| 37 for index, r in enumerate(failure_runs): | 37 for index, r in enumerate(failure_runs): |
| 38 if filter_function(r.time_finished): | 38 if filter_function(r.time_finished): |
| 39 r.patchset_url = patchsets[index].getURL() | 39 r.patchset_url = patchsets[index].getURL() |
| 40 r.builder = patchsets[index].builder | 40 r.builder = patchsets[index].builder |
| 41 r.formatted_time = time_formatter(r.time_finished) | 41 r.formatted_time = time_formatter(r.time_finished) |
| 42 filtered_occurrences.append(r) | 42 filtered_occurrences.append(r) |
| 43 | 43 |
| 44 # Do simple sorting of occurances by builder to make reading easier. | 44 # Do simple sorting of occurrences by builder to make reading easier. |
| 45 return sorted(filtered_occurrences, key=FlakeSortFunction) | 45 return sorted(filtered_occurrences, key=FlakeSortFunction) |
| 46 | 46 |
| 47 | 47 |
| 48 class Index(webapp2.RequestHandler): # pragma: no cover | 48 class Index(webapp2.RequestHandler): # pragma: no cover |
| 49 def get(self): | 49 def get(self): |
| 50 time_range = self.request.get('range', default_value='day') | 50 time_range = self.request.get('range', default_value='day') |
| 51 cursor = Cursor(urlsafe=self.request.get('cursor')) | 51 cursor = Cursor(urlsafe=self.request.get('cursor')) |
| 52 flakes_query = Flake.query() | 52 flakes_query = Flake.query() |
| 53 if time_range == 'hour': | 53 if time_range == 'hour': |
| 54 flakes_query = flakes_query.filter(Flake.last_hour == True) | 54 flakes_query = flakes_query.filter(Flake.last_hour == True) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 f.filtered_occurrences = GetFilteredOccurences( | 96 f.filtered_occurrences = GetFilteredOccurences( |
| 97 f, time_formatter, filter_by_range) | 97 f, time_formatter, filter_by_range) |
| 98 | 98 |
| 99 values = { | 99 values = { |
| 100 'range': time_range, | 100 'range': time_range, |
| 101 'flakes': flakes, | 101 'flakes': flakes, |
| 102 'more': more, | 102 'more': more, |
| 103 'cursor': next_cursor.urlsafe() if next_cursor else '', | 103 'cursor': next_cursor.urlsafe() if next_cursor else '', |
| 104 } | 104 } |
| 105 self.response.write(template.render('templates/index.html', values)) | 105 self.response.write(template.render('templates/index.html', values)) |
| OLD | NEW |