| 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 as status | 7 from model import analysis_status as status |
| 8 from model.wf_suspected_cl import WfSuspectedCL |
| 8 | 9 |
| 9 | 10 |
| 10 class WfCulprit(ndb.Model): | 11 class WfCulprit(WfSuspectedCL): |
| 11 """Represents a culprit that causes a group of failures on Chromium waterfall. | 12 """Represents a culprit that causes a group of failures on Chromium waterfall. |
| 12 | 13 |
| 13 'Wf' is short for waterfall. | 14 'Wf' is short for waterfall. |
| 14 """ | 15 """ |
| 15 | 16 |
| 16 # Repo or project name of the culprit, eg: chromium, etc. | |
| 17 repo_name = ndb.StringProperty(indexed=True) | |
| 18 | |
| 19 # The Git hash revision of the culprit. | |
| 20 revision = ndb.StringProperty(indexed=False) | |
| 21 | |
| 22 # The commit position of the culprit. Might not be available for some repo. | |
| 23 commit_position = ndb.IntegerProperty(indexed=False) | |
| 24 | |
| 25 # When the code-review of this culprit was notified. | 17 # When the code-review of this culprit was notified. |
| 26 cr_notification_time = ndb.DateTimeProperty(indexed=True) | 18 cr_notification_time = ndb.DateTimeProperty(indexed=True) |
| 27 | 19 |
| 28 # The status of code-review notification: None, RUNNING, COMPLETED, ERROR. | 20 # The status of code-review notification: None, RUNNING, COMPLETED, ERROR. |
| 29 cr_notification_status = ndb.IntegerProperty(indexed=True) | 21 cr_notification_status = ndb.IntegerProperty(indexed=True) |
| 30 | 22 |
| 31 # The list of builds in which the culprit caused some breakage. | |
| 32 builds = ndb.JsonProperty(indexed=False) | |
| 33 | |
| 34 @property | |
| 35 def project_name(self): | |
| 36 return self.repo_name | |
| 37 | |
| 38 @property | 23 @property |
| 39 def cr_notification_processed(self): | 24 def cr_notification_processed(self): |
| 40 return self.cr_notification_status in (status.COMPLETED, status.RUNNING) | 25 return self.cr_notification_status in (status.COMPLETED, status.RUNNING) |
| 41 | 26 |
| 42 @property | 27 @property |
| 43 def cr_notified(self): | 28 def cr_notified(self): |
| 44 return self.cr_notification_status == status.COMPLETED | 29 return self.cr_notification_status == status.COMPLETED |
| 45 | |
| 46 @classmethod | |
| 47 def _CreateKey(cls, repo_name, revision): # pragma: no cover | |
| 48 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) | |
| 49 | |
| 50 @classmethod | |
| 51 def Create(cls, repo_name, revision, commit_position): # pragma: no cover | |
| 52 instance = cls(key=cls._CreateKey(repo_name, revision)) | |
| 53 instance.repo_name = repo_name | |
| 54 instance.revision = revision | |
| 55 instance.commit_position = commit_position | |
| 56 instance.builds = [] | |
| 57 return instance | |
| 58 | |
| 59 @classmethod | |
| 60 def Get(cls, repo_name, revision): # pragma: no cover | |
| 61 return cls._CreateKey(repo_name, revision).get() | |
| OLD | NEW |