| 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 appengine_util | 7 from common import appengine_util |
| 8 from common import time_util | 8 from common import time_util |
| 9 from model import triage_status | 9 from model import triage_status |
| 10 | 10 |
| 11 | 11 |
| 12 class TriageResult(ndb.Model): | 12 class TriageResult(ndb.Model): |
| 13 # The user who updated this result. | 13 # The user who updated this result. |
| 14 user_name = ndb.StringProperty(default=None, indexed=False) | 14 user_name = ndb.StringProperty(default=None, indexed=False) |
| 15 | 15 |
| 16 # The time this triage result was determined. | 16 # The time this triage result was determined. |
| 17 triaged_time = ndb.DateTimeProperty(indexed=False, auto_now=True) | 17 triaged_time = ndb.DateTimeProperty(indexed=False, auto_now=True) |
| 18 | 18 |
| 19 # The result of the analysis as correct or not. If not triaged, the value | 19 # The result of the analysis as correct or not. If the analysis is not yet |
| 20 # should be None. Other traige result codes are up to the child class to set. | 20 # completed, then the value should be None. Other traige result codes are up |
| 21 # to the child class to set. |
| 21 triage_result = ndb.IntegerProperty(default=None, indexed=True) | 22 triage_result = ndb.IntegerProperty(default=None, indexed=True) |
| 22 | 23 |
| 23 # The version of findit that generated this result. Should primarily be | 24 # The version of findit that generated this result. Should primarily be |
| 24 # relevant for entities that are not versioned. | 25 # relevant for entities that are not versioned. |
| 25 findit_version = ndb.StringProperty(default=None, indexed=False) | 26 findit_version = ndb.StringProperty(default=None, indexed=False) |
| 26 | 27 |
| 27 # The version number of the entity that is being triaged. Should primarily be | 28 # The version number of the entity that is being triaged. Should primarily be |
| 28 # relevant for versioned entites. | 29 # relevant for versioned entites. |
| 29 version_number = ndb.IntegerProperty(default=None, indexed=False) | 30 version_number = ndb.IntegerProperty(default=None, indexed=False) |
| 30 | 31 |
| 31 # Other information about this result. For example, cl_info for suspected CLs | 32 # Other information about this result. For example, cl_info for suspected CLs |
| 32 # which may contain repo/revision or the suspected range for a flake analysis. | 33 # which may contain repo/revision or the suspected range for a flake analysis. |
| 33 suspect_info = ndb.JsonProperty(default=None, indexed=False) | 34 suspect_info = ndb.JsonProperty(default=None, indexed=False) |
| 34 | 35 |
| 35 | 36 |
| 36 class TriagedModel(ndb.Model): | 37 class TriagedModel(ndb.Model): |
| 37 """The parent class for models that can have traige results.""" | 38 """The parent class for models that can have triage results.""" |
| 38 | 39 |
| 39 def UpdateTriageResult(self, triage_result, suspect_info, user_name, | 40 def UpdateTriageResult(self, triage_result, suspect_info, user_name, |
| 40 version_number=None): | 41 version_number=None): |
| 41 result = TriageResult() | 42 result = TriageResult() |
| 42 result.user_name = user_name | 43 result.user_name = user_name |
| 43 result.triage_result = triage_result | 44 result.triage_result = triage_result |
| 44 result.findit_version = appengine_util.GetCurrentVersion() | 45 result.findit_version = appengine_util.GetCurrentVersion() |
| 45 result.version_number = version_number | 46 result.version_number = version_number |
| 46 result.suspect_info = suspect_info | 47 result.suspect_info = suspect_info |
| 47 self.triage_history.append(result) | 48 self.triage_history.append(result) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 triage_record.triage_result)), | 60 triage_record.triage_result)), |
| 60 'findit_version': triage_record.findit_version, | 61 'findit_version': triage_record.findit_version, |
| 61 'version_number': triage_record.version_number | 62 'version_number': triage_record.version_number |
| 62 }) | 63 }) |
| 63 | 64 |
| 64 return triage_history | 65 return triage_history |
| 65 | 66 |
| 66 # Record the triage result history. | 67 # Record the triage result history. |
| 67 triage_history = ndb.LocalStructuredProperty( | 68 triage_history = ndb.LocalStructuredProperty( |
| 68 TriageResult, repeated=True, indexed=False, compressed=True) | 69 TriageResult, repeated=True, indexed=False, compressed=True) |
| OLD | NEW |