Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 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 from common import constants | |
| 8 from common.waterfall import failure_type | |
| 9 from model.base_build_model import BaseBuildModel | |
| 10 from model import analysis_status | |
| 11 from model import result_status | |
| 12 | |
| 13 | |
| 14 class BaseAnalysis(ndb.Model): | |
| 15 """Represents an analysis of a build of a builder in a Chromium waterfall. | |
| 16 """ | |
| 17 | |
| 18 @property | |
| 19 def completed(self): | |
|
stgao
2016/07/14 18:01:32
Should this and some other properties below belong
caiw
2016/07/15 00:57:59
Per offline discussion, I think we are keeping the
| |
| 20 return self.status in ( | |
| 21 analysis_status.COMPLETED, analysis_status.ERROR) | |
| 22 | |
| 23 @property | |
| 24 def duration(self): | |
| 25 if not self.completed or not self.end_time or not self.start_time: | |
| 26 return None | |
| 27 | |
| 28 return int((self.end_time - self.start_time).total_seconds()) | |
| 29 | |
| 30 @property | |
| 31 def failed(self): | |
| 32 return self.status == analysis_status.ERROR | |
| 33 | |
| 34 @property | |
| 35 def status_description(self): | |
| 36 return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown') | |
| 37 | |
| 38 @property | |
| 39 def result_status_description(self): | |
| 40 return result_status.RESULT_STATUS_TO_DESCRIPTION.get( | |
| 41 self.result_status, '') | |
| 42 | |
| 43 @property | |
| 44 def correct(self): | |
| 45 """Returns whether the analysis result is correct or not. | |
| 46 | |
| 47 Returns: | |
| 48 True: correct | |
| 49 False: incorrect | |
| 50 None: don't know yet. | |
| 51 """ | |
| 52 if not self.completed or self.failed: | |
| 53 return None | |
| 54 | |
| 55 if self.result_status in ( | |
|
stgao
2016/07/14 18:01:33
``result_status`` is not defined in this model.
caiw
2016/07/15 00:57:59
Ok it seems like result_status is more of a wf thi
| |
| 56 result_status.FOUND_CORRECT, | |
| 57 result_status.NOT_FOUND_CORRECT, | |
| 58 result_status.FOUND_CORRECT_DUPLICATE): | |
| 59 return True | |
| 60 | |
| 61 if self.result_status in ( | |
| 62 result_status.FOUND_INCORRECT, | |
| 63 result_status.NOT_FOUND_INCORRECT, | |
| 64 result_status.FOUND_INCORRECT_DUPLICATE): | |
| 65 return False | |
| 66 | |
| 67 return None | |
| 68 | |
| 69 # The url path to the pipeline status page. | |
| 70 pipeline_status_path = ndb.StringProperty(indexed=False) | |
| 71 | |
| 72 # The status of the analysis. | |
| 73 status = ndb.IntegerProperty( | |
| 74 default=analysis_status.PENDING, indexed=False) | |
| 75 # When the analysis was requested. | |
| 76 request_time = ndb.DateTimeProperty(indexed=False) | |
| 77 # When the analysis actually started. | |
| 78 start_time = ndb.DateTimeProperty(indexed=False) | |
|
stgao
2016/07/14 18:01:32
These seems almost the same as those in progress.p
caiw
2016/07/15 00:57:59
Per offline discussion, we will leave this until l
| |
| 79 # When the analysis actually ended. | |
| 80 end_time = ndb.DateTimeProperty(indexed=False) | |
| 81 # When the analysis was updated. | |
| 82 updated_time = ndb.DateTimeProperty(indexed=False, auto_now=True) | |
| 83 # Record which version of analysis. | |
| 84 version = ndb.StringProperty(indexed=False) | |
| OLD | NEW |