| 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 common import time_util |
| 8 |
| 7 | 9 |
| 8 class BaseSuspectedCL(ndb.Model): | 10 class BaseSuspectedCL(ndb.Model): |
| 9 """Represents base information about a suspected cl.""" | 11 """Represents base information about a suspected cl.""" |
| 10 | 12 |
| 11 # Repo or project name of the suspected CL, eg: chromium, etc. | 13 # Repo or project name of the suspected CL, eg: chromium, etc. |
| 12 repo_name = ndb.StringProperty(indexed=True) | 14 repo_name = ndb.StringProperty(indexed=True) |
| 13 | 15 |
| 14 # The Git hash revision of the suspected CL. | 16 # The Git hash revision of the suspected CL. |
| 15 revision = ndb.StringProperty(indexed=False) | 17 revision = ndb.StringProperty(indexed=False) |
| 16 | 18 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 @classmethod | 33 @classmethod |
| 32 def _CreateKey(cls, repo_name, revision): # pragma: no cover | 34 def _CreateKey(cls, repo_name, revision): # pragma: no cover |
| 33 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) | 35 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) |
| 34 | 36 |
| 35 @classmethod | 37 @classmethod |
| 36 def Create(cls, repo_name, revision, commit_position): # pragma: no cover | 38 def Create(cls, repo_name, revision, commit_position): # pragma: no cover |
| 37 instance = cls(key=cls._CreateKey(repo_name, revision)) | 39 instance = cls(key=cls._CreateKey(repo_name, revision)) |
| 38 instance.repo_name = repo_name | 40 instance.repo_name = repo_name |
| 39 instance.revision = revision | 41 instance.revision = revision |
| 40 instance.commit_position = commit_position | 42 instance.commit_position = commit_position |
| 43 instance.identified_time = time_util.GetUTCNow() |
| 41 return instance | 44 return instance |
| 42 | 45 |
| 43 @classmethod | 46 @classmethod |
| 44 def Get(cls, repo_name, revision): # pragma: no cover | 47 def Get(cls, repo_name, revision): # pragma: no cover |
| 45 return cls._CreateKey(repo_name, revision).get() | 48 return cls._CreateKey(repo_name, revision).get() |
| OLD | NEW |