Chromium Code Reviews| Index: appengine/findit/model/build_analysis.py |
| diff --git a/appengine/findit/model/build_analysis.py b/appengine/findit/model/build_analysis.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aaba744bda12b2f1e88485921c1006d161d3a69e |
| --- /dev/null |
| +++ b/appengine/findit/model/build_analysis.py |
| @@ -0,0 +1,50 @@ |
| +# Copyright (c) 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 |
| + |
| +from model.build_analysis_status import BuildAnalysisStatus |
| + |
| + |
| +class BuildAnalysis(ndb.Model): |
| + """Represent an analysis of a build cycle of a builder in a waterfall.""" |
|
qyearsley
2014/12/29 19:44:53
As for functions, I think that verbs in docstrings
stgao
2015/01/03 01:31:47
Done.
|
| + |
| + @staticmethod |
| + def CreateKey(master_name, builder_name, build_number): # pragma: no cover |
| + return ndb.Key('Master', master_name, 'Builder', builder_name, |
| + 'BuildAnalysis', build_number) |
| + |
| + @staticmethod |
| + def CreateBuildAnalysis( |
| + master_name, builder_name, build_number): # pragma: no cover |
| + """Create a BuildAnalysis instance, but not save it to datastore.""" |
|
qyearsley
2014/12/29 19:44:53
You can change this to:
"""Creates a BuildAnalysis
stgao
2015/01/03 01:31:47
Done.
|
| + return BuildAnalysis( |
| + key=BuildAnalysis.CreateKey(master_name, builder_name, build_number), |
| + master_name=master_name, |
| + builder_name=builder_name, |
| + build_number=build_number) |
| + |
| + @staticmethod |
| + def GetBuildAnalysis( |
| + master_name, builder_name, build_number): # pragma: no cover |
| + return BuildAnalysis.CreateKey( |
| + master_name, builder_name, build_number).get() |
| + |
| + def Reset(self): |
| + """Reset to the state as if no analysis is run.""" |
| + self.status = BuildAnalysisStatus.PENDING |
| + self.start_time = None |
| + self.updated_time = None |
| + |
| + # Information of the analyzed build. |
| + master_name = ndb.StringProperty(indexed=False) |
| + builder_name = ndb.StringProperty(indexed=False) |
| + build_number = ndb.IntegerProperty(indexed=False) |
|
qyearsley
2014/12/29 19:44:53
Since master_name, builder_name and build_number a
stgao
2015/01/03 01:31:47
Good idea! I created a base class for this, becaus
|
| + build_start_time = ndb.DateTimeProperty(indexed=True) |
| + |
| + # Information of analysis processing. |
| + status = ndb.IntegerProperty( |
| + default=BuildAnalysisStatus.PENDING, indexed=False) |
| + start_time = ndb.DateTimeProperty(indexed=False) |
| + updated_time = ndb.DateTimeProperty(indexed=False) |