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

Side by Side Diff: appengine/findit/model/base_flake_model.py

Issue 2124973003: These are the database objects used while finding the regression range. 1/3 (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Database objects post offline discussion Created 4 years, 5 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
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.ext import ndb 5 from google.appengine.ext import ndb
6 6
7 7
8 class BaseBuildModel(ndb.Model): # pragma: no cover 8 class BaseFlakeModel(ndb.Model): # pragma: no cover
9 """A base class to provide computed properties from the key. 9 """A base class to provide computed properties from the key.
10 10
11 The computed properties are master name, builder name, and build number. 11 The computed properties are master name, builder name, and build number.
12 Subclasses should set its key as: 12 Subclasses should set its key as:
13 build_id = BaseBuildModel.CreateBuildId( 13 build_id = BaseBuildModel.CreateBuildId(
14 master_name, builder_name, build_number) 14 master_name, builder_name, build_number)
15 ndb.Key('KindName', build_id, 'Optional_KindName', optional_id, ...) 15 ndb.Key('KindName', build_id, 'Optional_KindName', optional_id, ...)
16 """ 16 """
17 17
18 @staticmethod 18 @staticmethod
19 def CreateBuildId(master_name, builder_name, build_number): 19 def CreateFlakeId(master_name, builder_name, step_name, build_number):
20 return '%s/%s/%s' % (master_name, builder_name, build_number) 20 return '%s/%s/%s/%s' % (master_name, builder_name, step_name, build_number)
stgao 2016/07/14 18:01:33 Is there a special consideration of putting step n
21 21
22 @ndb.ComputedProperty 22 @ndb.ComputedProperty
23 def master_name(self): 23 def master_name(self):
24 return self.key.pairs()[0][1].split('/')[0] 24 return self.key.pairs()[0][1].split('/')[0]
25 25
26 @ndb.ComputedProperty 26 @ndb.ComputedProperty
27 def builder_name(self): 27 def builder_name(self):
28 return self.key.pairs()[0][1].split('/')[1] 28 return self.key.pairs()[0][1].split('/')[1]
29 29
30 @ndb.ComputedProperty 30 @ndb.ComputedProperty
31 def step_name(self):
32 return self.key.pairs()[0][1].split('/')[2]
33
34 @ndb.ComputedProperty
31 def build_number(self): 35 def build_number(self):
32 return int(self.key.pairs()[0][1].split('/')[2]) 36 return int(self.key.pairs()[0][1].split('/')[3]
37 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698