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 | 7 |
| 8 class WfSuspectedCL(ndb.Model): | 8 class BaseCL(ndb.Model): |
| 9 """Represents suspected cl that causes failures on Chromium waterfall builds. | 9 """Represents base information about a suspected cl.""" |
|
lijeffrey
2016/09/08 22:09:23
nit: it seems this docstring should now be "... in
chanli
2016/09/08 22:32:28
I think it's still a suspected cl. changed the mod
| |
| 10 | |
| 11 'Wf' is short for waterfall. | |
| 12 """ | |
| 13 | 10 |
| 14 # Repo or project name of the suspected CL, eg: chromium, etc. | 11 # Repo or project name of the suspected CL, eg: chromium, etc. |
| 15 repo_name = ndb.StringProperty(indexed=True) | 12 repo_name = ndb.StringProperty(indexed=True) |
| 16 | |
| 17 # The Git hash revision of the suspected CL. | 13 # The Git hash revision of the suspected CL. |
| 18 revision = ndb.StringProperty(indexed=False) | 14 revision = ndb.StringProperty(indexed=False) |
| 19 | |
| 20 # The commit position of the suspected CL. | 15 # The commit position of the suspected CL. |
| 21 # Might not be available for some repo. | 16 # Might not be available for some repo. |
| 22 commit_position = ndb.IntegerProperty(indexed=False) | 17 commit_position = ndb.IntegerProperty(indexed=False) |
| 23 | 18 |
| 24 # The list of builds in which the suspected CL caused some breakage. | 19 # Time when the CL was identified as a suspect for the first time. |
| 25 builds = ndb.JsonProperty(indexed=False) | 20 identified_time = ndb.DateTimeProperty(indexed=False) |
| 26 | 21 # Time when the CL was updated. |
| 27 # Is the suspected CL the culprit or not. | 22 updated_time = ndb.DateTimeProperty(indexed=True) |
| 28 is_culprit = ndb.BooleanProperty(indexed=True, default=None) | |
| 29 | |
| 30 # From which approach do we get this suspected CL: HEURISTIC, TRY_JOB or BOTH. | |
| 31 approach = ndb.IntegerProperty(indexed=True) | |
| 32 | |
| 33 # Failure type: failure_type.COMPILE or failure_type.TEST. | |
| 34 failure_type = ndb.IntegerProperty(indexed=True) | |
| 35 | 23 |
| 36 @property | 24 @property |
| 37 def project_name(self): | 25 def project_name(self): |
| 38 return self.repo_name | 26 return self.repo_name |
| 39 | 27 |
| 40 @classmethod | 28 @classmethod |
| 41 def _CreateKey(cls, repo_name, revision): # pragma: no cover | 29 def _CreateKey(cls, repo_name, revision): # pragma: no cover |
| 42 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) | 30 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) |
| 43 | 31 |
| 44 @classmethod | 32 @classmethod |
| 45 def Create(cls, repo_name, revision, commit_position): # pragma: no cover | 33 def Create(cls, repo_name, revision, commit_position): # pragma: no cover |
| 46 instance = cls(key=cls._CreateKey(repo_name, revision)) | 34 instance = cls(key=cls._CreateKey(repo_name, revision)) |
| 47 instance.repo_name = repo_name | 35 instance.repo_name = repo_name |
| 48 instance.revision = revision | 36 instance.revision = revision |
| 49 instance.commit_position = commit_position | 37 instance.commit_position = commit_position |
| 50 instance.builds = [] | |
| 51 return instance | 38 return instance |
| 52 | 39 |
| 53 @classmethod | 40 @classmethod |
| 54 def Get(cls, repo_name, revision): # pragma: no cover | 41 def Get(cls, repo_name, revision): # pragma: no cover |
| 55 return cls._CreateKey(repo_name, revision).get() | 42 return cls._CreateKey(repo_name, revision).get() |
| OLD | NEW |