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

Unified Diff: appengine/findit/model/base_build_model.py

Issue 820113002: [Findit] Add a sub-pipeline to detect first-known failure. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments Created 5 years, 11 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 | « appengine/findit/app.yaml ('k') | appengine/findit/model/build.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/model/base_build_model.py
diff --git a/appengine/findit/model/base_build_model.py b/appengine/findit/model/base_build_model.py
new file mode 100644
index 0000000000000000000000000000000000000000..73a9f84dd1741ac77df461882f852899f943be6f
--- /dev/null
+++ b/appengine/findit/model/base_build_model.py
@@ -0,0 +1,32 @@
+# Copyright 2014 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
+
+
+class BaseBuildModel(ndb.Model): # pragma: no cover
+ """A base class to provide computed properties from the key.
+
+ The computed properties are master name, builder name, and build number.
+ Subclasses should set its key as:
+ build_id = BaseBuildModel.CreateBuildId(
+ master_name, builder_name, build_number)
+ ndb.Key('KindName', build_id, 'Optional_KindName', optional_id, ...)
+ """
+
+ @staticmethod
+ def CreateBuildId(master_name, builder_name, build_number):
+ return '%s/%s/%s' % (master_name, builder_name, build_number)
+
+ @ndb.ComputedProperty
+ def master_name(self):
+ return self.key.pairs()[0][1].split('/')[0]
+
+ @ndb.ComputedProperty
+ def builder_name(self):
+ return self.key.pairs()[0][1].split('/')[1]
+
+ @ndb.ComputedProperty
+ def build_number(self):
+ return int(self.key.pairs()[0][1].split('/')[2])
« no previous file with comments | « appengine/findit/app.yaml ('k') | appengine/findit/model/build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698