Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 from model.base_try_job_data import BaseTryJobData | |
| 7 | 8 |
| 8 class WfTryJobData(ndb.Model): | 9 |
| 9 """Represents a tryjob's data for a completed try job.""" | 10 class WfTryJobData(BaseTryJobData): |
| 10 # The original master on which the build was detected to have failed. | 11 """Represents a tryjob's data for a completed compile or test try job.""" |
| 11 master_name = ndb.StringProperty(indexed=True) | 12 # Number of commits in the revision range. |
| 12 # The original buildername on which the build was detected to have failed. | 13 regression_range_size = ndb.IntegerProperty(indexed=False) |
| 13 builder_name = ndb.StringProperty(indexed=True) | 14 |
| 14 # The original build number. | 15 # Number of commits analyzed to determine a culprit if any. |
| 15 build_number = ndb.IntegerProperty(indexed=True) | 16 number_of_commits_analyzed = ndb.IntegerProperty(indexed=False) |
| 17 | |
| 18 # Culprit(s) determined to have caused the failure, if any. | |
| 19 culprits = ndb.JsonProperty(indexed=False) | |
| 20 | |
| 21 # Whether or not the try job had compile targets passed (compile only). | |
| 22 has_compile_targets = ndb.BooleanProperty(indexed=True) | |
| 23 | |
| 24 # Whether or not the try job had heuristic results to guide it. | |
| 25 has_heuristic_results = ndb.BooleanProperty(indexed=True) | |
| 26 | |
| 16 # The type of try job, such as 'compile' or 'test'. | 27 # The type of try job, such as 'compile' or 'test'. |
| 17 try_job_type = ndb.StringProperty(indexed=True) | 28 try_job_type = ndb.StringProperty(indexed=True) |
| 18 # When the try job was created. | 29 |
| 19 request_time = ndb.DateTimeProperty(indexed=True) | 30 @property |
|
stgao
2017/01/05 21:15:11
Go with @ComputedProperty so that new data works t
lijeffrey
2017/01/06 04:22:21
Done.
| |
| 20 # When the try job began executing. | 31 def master_name(self): |
| 21 start_time = ndb.DateTimeProperty(indexed=True) | 32 return self.try_job_key.pairs()[0][1].split('/')[0] |
| 22 # When the try job completed. | 33 |
| 23 end_time = ndb.DateTimeProperty(indexed=True) | 34 @property |
| 24 # Number of commits in the revision range. | 35 def builder_name(self): |
| 25 regression_range_size = ndb.IntegerProperty(indexed=False) | 36 return self.try_job_key.pairs()[0][1].split('/')[1] |
| 26 # Number of commits analyzed to determine a culprit if any. | 37 |
| 27 number_of_commits_analyzed = ndb.IntegerProperty(indexed=False) | 38 @property |
| 28 # Culprit(s) determined to have caused the failure, if any. | 39 def build_number(self): |
| 29 culprits = ndb.JsonProperty(indexed=False) | 40 return int(self.try_job_key.pairs()[0][1].split('/')[2]) |
| 30 # The url to the try job build page. | |
| 31 try_job_url = ndb.StringProperty(indexed=False) | |
| 32 # Error message and reason, if any. | |
| 33 error = ndb.JsonProperty(indexed=False) | |
| 34 # Error code if anything went wrong with the try job. | |
| 35 error_code = ndb.IntegerProperty(indexed=True) | |
| 36 # The last buildbucket build response received. | |
| 37 last_buildbucket_response = ndb.JsonProperty(indexed=False, compressed=True) | |
| 38 # Whether or not the try job had compile targets passed (compile only). | |
| 39 has_compile_targets = ndb.BooleanProperty(indexed=True) | |
| 40 # Whether or not the try job had heuristic results to guide it. | |
| 41 has_heuristic_results = ndb.BooleanProperty(indexed=True) | |
| 42 | 41 |
| 43 @staticmethod | 42 @staticmethod |
| 44 def _CreateKey(build_id): # pragma: no cover | 43 def _CreateKey(build_id): # pragma: no cover |
| 45 return ndb.Key('WfTryJobData', build_id) | 44 return ndb.Key('WfTryJobData', build_id) |
| 46 | 45 |
| 47 @staticmethod | 46 @staticmethod |
| 48 def Create(build_id): # pragma: no cover | 47 def Create(build_id): # pragma: no cover |
| 49 return WfTryJobData(key=WfTryJobData._CreateKey(build_id)) | 48 return WfTryJobData(key=WfTryJobData._CreateKey(build_id)) |
| 50 | 49 |
| 51 @staticmethod | 50 @staticmethod |
| 52 def Get(build_id): # pragma: no cover | 51 def Get(build_id): # pragma: no cover |
| 53 return WfTryJobData._CreateKey(build_id).get() | 52 return WfTryJobData._CreateKey(build_id).get() |
| 54 | 53 |
| OLD | NEW |