Chromium Code Reviews| Index: appengine/findit/model/base_analysis.py |
| diff --git a/appengine/findit/model/base_analysis.py b/appengine/findit/model/base_analysis.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1dc2ba6f9f9bc51608985b54ed761b82465fe018 |
| --- /dev/null |
| +++ b/appengine/findit/model/base_analysis.py |
| @@ -0,0 +1,53 @@ |
| +# Copyright 2016 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 common import constants |
| +from common.waterfall import failure_type |
| +from model.base_build_model import BaseBuildModel |
| +from model import analysis_status |
| +from model import result_status |
|
chanli
2016/07/19 19:12:20
constants, failure_type, BaseBuildModel and result
caiw
2016/07/19 19:36:09
Done.
|
| + |
| + |
| +class BaseAnalysis(ndb.Model): |
| + """Represents an analysis of a build of a builder in a Chromium waterfall. |
| + """ |
| + |
| + @property |
| + def completed(self): |
| + return self.status in ( |
| + analysis_status.COMPLETED, analysis_status.ERROR) |
| + |
| + @property |
| + def duration(self): |
| + if not self.completed or not self.end_time or not self.start_time: |
| + return None |
| + |
| + return int((self.end_time - self.start_time).total_seconds()) |
| + |
| + @property |
| + def failed(self): |
| + return self.status == analysis_status.ERROR |
| + |
| + @property |
| + def status_description(self): |
| + return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown') |
| + |
| + # The url path to the pipeline status page. |
| + pipeline_status_path = ndb.StringProperty(indexed=False) |
| + |
| + # The status of the analysis. |
| + status = ndb.IntegerProperty( |
| + default=analysis_status.PENDING, indexed=False) |
| + # When the analysis was requested. |
| + request_time = ndb.DateTimeProperty(indexed=False) |
| + # When the analysis actually started. |
| + start_time = ndb.DateTimeProperty(indexed=False) |
| + # When the analysis actually ended. |
| + end_time = ndb.DateTimeProperty(indexed=False) |
| + # When the analysis was updated. |
| + updated_time = ndb.DateTimeProperty(indexed=False, auto_now=True) |
| + # Record which version of analysis. |
| + version = ndb.StringProperty(indexed=False) |