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

Unified Diff: appengine/findit/handlers/culprit.py

Issue 2085513003: [Findit] Show the list of failed build cycles that a culprit is responsible for. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@group_same_failures
Patch Set: Add unittests. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/findit/handlers/test/culprit_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/handlers/culprit.py
diff --git a/appengine/findit/handlers/culprit.py b/appengine/findit/handlers/culprit.py
new file mode 100644
index 0000000000000000000000000000000000000000..1575f0e24a46a586dfa3dd4d748d66dd56bc6aee
--- /dev/null
+++ b/appengine/findit/handlers/culprit.py
@@ -0,0 +1,43 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from google.appengine.ext import ndb
+
+from common.base_handler import BaseHandler
+from common.base_handler import Permission
+
+
+def _FormatDatetime(dt):
+ if not dt:
+ return None # pragma: no cover
+ else:
+ return dt.strftime('%Y-%m-%d %H:%M:%S UTC')
+
+
+class Culprit(BaseHandler):
+ PERMISSION_LEVEL = Permission.ANYONE
+
+ def HandleGet(self):
+ """Lists the build cycles in which the culprit caused failures."""
+ key = self.request.get('key', '')
+
+ culprit = ndb.Key(urlsafe=key).get()
+ if not culprit: # pragma: no cover
+ return self.CreateError('Culprit not found', 404)
+
+ def ConvertBuildInfoToADict(build_info):
+ return {
+ 'master_name': build_info[0],
+ 'builder_name': build_info[1],
+ 'build_number': build_info[2],
+ }
+
+ data = {
+ 'project_name': culprit.project_name,
+ 'revision': culprit.revision,
+ 'cr_notified': culprit.cr_notified,
+ 'cr_notification_time': _FormatDatetime(culprit.cr_notification_time),
+ 'builds': map(ConvertBuildInfoToADict, culprit.builds),
+ }
+ return {'template': 'waterfall/culprit.html', 'data': data}
« no previous file with comments | « no previous file | appengine/findit/handlers/test/culprit_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698