| 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 |
| 5 import hashlib |
| 4 import json | 6 import json |
| 5 import logging | 7 import logging |
| 6 | 8 |
| 7 from google.appengine.ext import ndb | 9 from google.appengine.ext import ndb |
| 8 | 10 |
| 9 from model import analysis_status | 11 from model import analysis_status |
| 10 from model import triage_status | 12 from model import triage_status |
| 11 | 13 |
| 12 | 14 |
| 13 class CrashAnalysis(ndb.Model): | 15 class CrashAnalysis(ndb.Model): |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 @property | 128 @property |
| 127 def failed(self): | 129 def failed(self): |
| 128 return self.status == analysis_status.ERROR | 130 return self.status == analysis_status.ERROR |
| 129 | 131 |
| 130 @property | 132 @property |
| 131 def duration(self): | 133 def duration(self): |
| 132 if not self.completed: | 134 if not self.completed: |
| 133 return None | 135 return None |
| 134 | 136 |
| 135 return int((self.completed_time - self.started_time).total_seconds()) | 137 return int((self.completed_time - self.started_time).total_seconds()) |
| 138 |
| 139 @classmethod |
| 140 def _CreateKey(cls, crash_identifiers): |
| 141 return ndb.Key(cls.__name__, hashlib.sha1( |
| 142 json.dumps(crash_identifiers, sort_keys=True)).hexdigest()) |
| 143 |
| 144 @classmethod |
| 145 def Get(cls, crash_identifiers): |
| 146 return cls._CreateKey(crash_identifiers).get() |
| 147 |
| 148 @classmethod |
| 149 def Create(cls, crash_identifiers): |
| 150 return cls(key=cls._CreateKey(crash_identifiers)) |
| OLD | NEW |