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

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: 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.
chanli 2016/07/07 23:38:27 nit: change the year to 2016, same for others
caiw 2016/07/14 00:59:39 Done.
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.
chanli 2016/07/07 23:38:27 Please change the docstring here: step_name is als
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, ...)
chanli 2016/07/07 23:38:27 Please update this part
caiw 2016/07/14 00:59:39 Done.
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):
chanli 2016/07/07 23:38:28 I would have the argument list as : master_name, b
caiw 2016/07/14 00:59:39 Done.
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)
chanli 2016/07/07 23:38:28 Is there a reason why you want to organize the key
caiw 2016/07/14 00:59:39 Done.
21 21
22 @ndb.ComputedProperty 22 @ndb.ComputedProperty
23 def master_name(self): 23 def master_name(self):
stgao 2016/07/08 22:51:26 Per discussion, we will use the BaseBuildModel dir
caiw 2016/07/14 00:59:39 Done.
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
« no previous file with comments | « no previous file | appengine/findit/model/base_swarming_task.py » ('j') | appengine/findit/model/base_swarming_task.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698