Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2216)

Unified Diff: appengine/findit/model/crash/crash_analysis.py

Issue 2322133002: [Findit] Add cracas_crash_analysis (Closed)
Patch Set: Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b876b3d7e82e40ee9a7ce0fb608bab8ac8e33d88..c5b63d7fdd9e8e52cda014d17d622b4115d5bc49 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 hashlib
import json
import logging
@@ -133,3 +135,16 @@ class CrashAnalysis(ndb.Model):
return None
return int((self.completed_time - self.started_time).total_seconds())
+
+ @classmethod
+ def _CreateKey(cls, crash_identifiers):
+ return ndb.Key(cls.__name__, hashlib.sha1(
+ json.dumps(crash_identifiers, sort_keys=True)).hexdigest())
+
+ @classmethod
+ def Get(cls, crash_identifiers):
+ return cls._CreateKey(crash_identifiers).get()
+
+ @classmethod
+ def Create(cls, crash_identifiers):
+ return cls(key=cls._CreateKey(crash_identifiers))
« no previous file with comments | « appengine/findit/model/crash/cracas_crash_analysis.py ('k') | appengine/findit/model/crash/fracas_crash_analysis.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698