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/model/base_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: Add appengine/findit/model/test/base_model_test.py 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
Index: appengine/findit/model/base_model.py
diff --git a/appengine/findit/model/base_model.py b/appengine/findit/model/base_model.py
new file mode 100644
index 0000000000000000000000000000000000000000..3f4c013ce3ebd12d18dd299187422f7544e54070
--- /dev/null
+++ b/appengine/findit/model/base_model.py
@@ -0,0 +1,27 @@
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
qyearsley 2015/01/07 06:59:46 Note, the "(c)" isn't necessary, and can be remove
stgao 2015/01/09 01:28:23 Good catch. Done for files in this CL. For other f
+# 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 BaseModel(ndb.Model): # pragma: no cover
+ """A base class to provide computed properties from the key.
qyearsley 2015/01/07 06:59:46 This looks like a good idea. Possible alternative
stgao 2015/01/09 01:28:23 I like BaseBuildModel better. Done.
+
+ The computed properties are master name, builder name, and build number.
+ Subclasses should set its key as:
+ ndb.Key('KindName', master_name, 'KindName', builder_name,
+ 'KindName', build_number, 'Optional_KindName', optional_id, ...)
+ """
+
+ @ndb.ComputedProperty
+ def master_name(self):
+ return self.key.pairs()[0][1]
+
+ @ndb.ComputedProperty
+ def builder_name(self):
+ return self.key.pairs()[1][1]
+
+ @ndb.ComputedProperty
+ def build_number(self):
+ return self.key.pairs()[2][1]

Powered by Google App Engine
This is Rietveld 408576698