Chromium Code Reviews| Index: appengine/findit/model/crash/crash_analysis.py |
| diff --git a/appengine/findit/model/crash/crash_analysis.py b/appengine/findit/model/crash/crash_analysis.py |
| index 59bcdf4d62f757c9f19470b8303fac6857b9a419..330b0492cb7d7b386edf2b8ce65a4ae2f62e8c77 100644 |
| --- a/appengine/findit/model/crash/crash_analysis.py |
| +++ b/appengine/findit/model/crash/crash_analysis.py |
| @@ -1,6 +1,8 @@ |
| # Copyright 2016 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import json |
| +import logging |
| from google.appengine.ext import ndb |
| @@ -64,7 +66,7 @@ class CrashAnalysis(ndb.Model): |
| # Triage results. |
| regression_range_triage_status = ndb.StringProperty( |
| indexed=True, default=triage_status.UNTRIAGED) |
| - culprit_regression_range = ndb.JsonProperty(indexed=False) |
| + culprit_regression_range = ndb.JsonProperty(indexed=False, default=[]) |
| suspected_cls_triage_status = ndb.StringProperty( |
| indexed=True, default=triage_status.UNTRIAGED) |
| @@ -72,35 +74,17 @@ class CrashAnalysis(ndb.Model): |
| suspected_project_triage_status = ndb.StringProperty( |
| indexed=True, default=triage_status.UNTRIAGED) |
| - culprit_project = ndb.JsonProperty(indexed=False, default=[]) |
| + culprit_project = ndb.StringProperty(indexed=False, default='') |
| suspected_components_triage_status = ndb.StringProperty( |
| indexed=True, default=triage_status.UNTRIAGED) |
| culprit_components = ndb.JsonProperty(indexed=False, default=[]) |
| - triage_history = ndb.JsonProperty(indexed=False) |
| + triage_history = ndb.JsonProperty(indexed=False, default=[]) |
| # Triage note. |
| note = ndb.StringProperty(indexed=False, default='') |
| - def ResultCorrect(self, result_property): |
| - """Returns triage result of a result property. |
| - |
| - True if the result is triaged-correct, False if triaged-incorrect, else |
| - return None. |
| - """ |
| - if not self.completed or self.failed: |
| - return None |
| - |
| - result_triage_status = getattr(self, '%s_triage_status' % result_property) |
| - if result_triage_status == triage_status.TRIAGED_CORRECT: |
| - return True |
| - |
| - if result_triage_status == triage_status.TRIAGED_INCORRECT: |
| - return False |
| - |
| - return None |
| - |
| def Reset(self): |
| self.pipeline_status_path = None |
| self.status = analysis_status.PENDING |
| @@ -112,6 +96,16 @@ class CrashAnalysis(ndb.Model): |
| self.found_suspects = None |
| self.solution = None |
| + def Update(self, update): |
| + try: |
| + for key, value in update.iteritems(): |
| + setattr(self, key, value) |
|
stgao
2016/06/16 17:32:05
What if the key is not an attribute of the entity?
Sharu Jiang
2016/06/21 20:28:50
This will be addressed in another cl which contain
|
| + |
| + return True |
| + except Exception: # pragma: no cover. |
| + logging.warning('Failed to update %s' % json.dumps(update)) |
| + return False |
| + |
| @property |
| def completed(self): |
| return self.status in ( |