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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # 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
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from google.appengine.ext import ndb
6
7
8 class BaseModel(ndb.Model): # pragma: no cover
9 """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.
10
11 The computed properties are master name, builder name, and build number.
12 Subclasses should set its key as:
13 ndb.Key('KindName', master_name, 'KindName', builder_name,
14 'KindName', build_number, 'Optional_KindName', optional_id, ...)
15 """
16
17 @ndb.ComputedProperty
18 def master_name(self):
19 return self.key.pairs()[0][1]
20
21 @ndb.ComputedProperty
22 def builder_name(self):
23 return self.key.pairs()[1][1]
24
25 @ndb.ComputedProperty
26 def build_number(self):
27 return self.key.pairs()[2][1]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698