| 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 from model import triage_status |
| 8 | 9 |
| 9 | 10 |
| 10 class CrashAnalysis(ndb.Model): | 11 class CrashAnalysis(ndb.Model): |
| 11 """Base class to represent an analysis of a Chrome/Clusterfuzz crash.""" | 12 """Base class to represent an analysis of a Chrome/Clusterfuzz crash.""" |
| 12 ################### Properties for the crash itself. ################### | 13 ################### Properties for the crash itself. ################### |
| 13 # In which version or revision of Chrome the crash occurred. Either a version | 14 # In which version or revision of Chrome the crash occurred. Either a version |
| 14 # number for Chrome build or a git commit hash/position for chromium build. | 15 # number for Chrome build or a git commit hash/position for chromium build. |
| 15 crashed_version = ndb.StringProperty(indexed=False) | 16 crashed_version = ndb.StringProperty(indexed=False) |
| 16 | 17 |
| 17 # The stack_trace_string. | 18 # The stack_trace_string. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 # When the analysis was completed. | 45 # When the analysis was completed. |
| 45 completed_time = ndb.DateTimeProperty(indexed=False) | 46 completed_time = ndb.DateTimeProperty(indexed=False) |
| 46 | 47 |
| 47 # Which version of findit produces this result. | 48 # Which version of findit produces this result. |
| 48 findit_version = ndb.StringProperty(indexed=False) | 49 findit_version = ndb.StringProperty(indexed=False) |
| 49 | 50 |
| 50 ################### Properties for the analysis result. ################### | 51 ################### Properties for the analysis result. ################### |
| 51 | 52 |
| 52 # Analysis results. | 53 # Analysis results. |
| 53 result = ndb.JsonProperty(compressed=True, indexed=False) | 54 result = ndb.JsonProperty(compressed=True, indexed=False, default={}) |
| 54 | 55 |
| 55 # Tags for query and monitoring. | 56 # Tags for query and monitoring. |
| 56 has_regression_range = ndb.BooleanProperty(indexed=True) | 57 has_regression_range = ndb.BooleanProperty(indexed=True) |
| 57 found_suspects = ndb.BooleanProperty(indexed=True) | 58 found_suspects = ndb.BooleanProperty(indexed=True) |
| 59 found_project = ndb.BooleanProperty(indexed=True) |
| 60 found_components = ndb.BooleanProperty(indexed=True) |
| 61 |
| 58 solution = ndb.StringProperty(indexed=True) # 'core', 'blame', etc. | 62 solution = ndb.StringProperty(indexed=True) # 'core', 'blame', etc. |
| 59 | 63 |
| 64 # Triage results. |
| 65 regression_range_triage_status = ndb.StringProperty( |
| 66 indexed=True, default=triage_status.UNTRIAGED) |
| 67 culprit_regression_range = ndb.JsonProperty(indexed=False) |
| 68 |
| 69 suspected_cls_triage_status = ndb.StringProperty( |
| 70 indexed=True, default=triage_status.UNTRIAGED) |
| 71 culprit_cls = ndb.JsonProperty(indexed=False, default=[]) |
| 72 |
| 73 suspected_project_triage_status = ndb.StringProperty( |
| 74 indexed=True, default=triage_status.UNTRIAGED) |
| 75 culprit_project = ndb.JsonProperty(indexed=False, default=[]) |
| 76 |
| 77 suspected_components_triage_status = ndb.StringProperty( |
| 78 indexed=True, default=triage_status.UNTRIAGED) |
| 79 culprit_components = ndb.JsonProperty(indexed=False, default=[]) |
| 80 |
| 81 triage_history = ndb.JsonProperty(indexed=False) |
| 82 |
| 83 # Triage note. |
| 84 note = ndb.StringProperty(indexed=False, default='') |
| 85 |
| 86 def ResultCorrect(self, result_property): |
| 87 """Returns triage result of a result property. |
| 88 |
| 89 True if the result is triaged-correct, False if triaged-incorrect, else |
| 90 return None. |
| 91 """ |
| 92 if not self.completed or self.failed: |
| 93 return None |
| 94 |
| 95 result_triage_status = getattr(self, '%s_triage_status' % result_property) |
| 96 if result_triage_status == triage_status.TRIAGED_CORRECT: |
| 97 return True |
| 98 |
| 99 if result_triage_status == triage_status.TRIAGED_INCORRECT: |
| 100 return False |
| 101 |
| 102 return None |
| 103 |
| 60 def Reset(self): | 104 def Reset(self): |
| 61 self.pipeline_status_path = None | 105 self.pipeline_status_path = None |
| 62 self.status = analysis_status.PENDING | 106 self.status = analysis_status.PENDING |
| 63 self.requested_time = None | 107 self.requested_time = None |
| 64 self.started_time = None | 108 self.started_time = None |
| 65 self.completed_time = None | 109 self.completed_time = None |
| 66 self.findit_version = None | 110 self.findit_version = None |
| 67 self.has_regression_range = None | 111 self.has_regression_range = None |
| 68 self.found_suspects = None | 112 self.found_suspects = None |
| 69 self.solution = None | 113 self.solution = None |
| 70 | 114 |
| 71 @property | 115 @property |
| 72 def completed(self): | 116 def completed(self): |
| 73 return self.status in ( | 117 return self.status in ( |
| 74 analysis_status.COMPLETED, analysis_status.ERROR) | 118 analysis_status.COMPLETED, analysis_status.ERROR) |
| 75 | 119 |
| 76 @property | 120 @property |
| 77 def failed(self): | 121 def failed(self): |
| 78 return self.status == analysis_status.ERROR | 122 return self.status == analysis_status.ERROR |
| 79 | 123 |
| 80 @property | 124 @property |
| 81 def duration(self): | 125 def duration(self): |
| 82 if not self.completed: | 126 if not self.completed: |
| 83 return None | 127 return None |
| 84 | 128 |
| 85 return int((self.completed_time - self.started_time).total_seconds()) | 129 return int((self.completed_time - self.started_time).total_seconds()) |
| OLD | NEW |