| 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 import analysis_status | 7 from model import analysis_status |
| 8 | 8 |
| 9 | 9 |
| 10 class BaseTryJob(ndb.Model): | 10 class BaseTryJob(ndb.Model): |
| 11 """Represents a base try job result.""" | 11 """Represents a base try job result.""" |
| 12 | 12 |
| 13 # The status of the try job. | 13 # The status of the try job. |
| 14 status = ndb.IntegerProperty( | 14 status = ndb.IntegerProperty( |
| 15 default=analysis_status.PENDING, indexed=False) | 15 default=analysis_status.PENDING, indexed=False) |
| 16 | 16 |
| 17 # A list of try job IDs associated with each try job for collecting metadata. | 17 # A list of try job IDs associated with each try job for collecting metadata. |
| 18 try_job_ids = ndb.JsonProperty(indexed=False, compressed=True) | 18 try_job_ids = ndb.JsonProperty(indexed=False, compressed=True) |
| 19 | 19 |
| 20 @property | 20 @property |
| 21 def completed(self): | 21 def completed(self): |
| 22 return self.status in ( | 22 return self.status in ( |
| 23 analysis_status.COMPLETED, analysis_status.ERROR) | 23 analysis_status.COMPLETED, analysis_status.ERROR) |
| 24 | 24 |
| 25 @property | 25 @property |
| 26 def failed(self): | 26 def failed(self): |
| 27 return self.status == analysis_status.ERROR | 27 return self.status == analysis_status.ERROR |
| 28 |
| 29 @classmethod |
| 30 def GetMasterName(cls, key): |
| 31 return key.pairs()[0][1].split('/')[0] |
| 32 |
| 33 @classmethod |
| 34 def GetBuilderName(cls, key): |
| 35 return key.pairs()[0][1].split('/')[1] |
| 36 |
| 37 @ndb.ComputedProperty |
| 38 def master_name(self): |
| 39 return self.GetMasterName(self.key) |
| 40 |
| 41 @ndb.ComputedProperty |
| 42 def builder_name(self): |
| 43 return self.GetBuilderName(self.key) |
| OLD | NEW |