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

Side by Side Diff: appengine/findit/model/crash/fracas_crash_analysis.py

Issue 1946513003: [Findit] Modify the handler for fracas input message. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comment. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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 import hashlib 5 import hashlib
6 import json
6 7
7 from google.appengine.ext import ndb 8 from google.appengine.ext import ndb
8 9
9 from model.crash.crash_analysis import CrashAnalysis 10 from model.crash.crash_analysis import CrashAnalysis
10 11
11 12
12 class FracasCrashAnalysis(CrashAnalysis): 13 class FracasCrashAnalysis(CrashAnalysis):
13 """Represents an analysis of a Chrome crash.""" 14 """Represents an analysis of a Chrome crash."""
14 # Data of crash per million page loads for each Chrome version. 15 # Customized properties for Fracas crash.
15 versions_to_cpm = ndb.JsonProperty(indexed=False) 16 historic_metadata = ndb.JsonProperty(indexed=False)
17 channel = ndb.StringProperty(indexed=False)
16 18
17 def Reset(self): 19 def Reset(self):
18 super(FracasCrashAnalysis, self).Reset() 20 super(FracasCrashAnalysis, self).Reset()
19 self.versions_to_cpm = None 21 self.historic_metadata = None
20 22 self.channel = None
21 @ndb.ComputedProperty
22 def channel(self):
23 return self.key.pairs()[0][1].split('/')[0]
24
25 @ndb.ComputedProperty
26 def platform(self):
27 return self.key.pairs()[0][1].split('/')[1]
28 23
29 @staticmethod 24 @staticmethod
30 def _CreateKey(channel, platform, signature): 25 def _CreateKey(crash_identifiers):
31 # Use sha1 hex digest of signature to avoid char conflict with '/'. 26 # Use sha1 hex digest of signature to avoid char conflict with '/'.
32 return ndb.Key('FracasCrashAnalysis', '%s/%s/%s' % ( 27 return ndb.Key('FracasCrashAnalysis', hashlib.sha1(
33 channel, platform, hashlib.sha1(signature).hexdigest())) 28 json.dumps(crash_identifiers, sort_keys=True)).hexdigest())
34 29
35 @classmethod 30 @classmethod
36 def Get(cls, channel, platform, signature): 31 def Get(cls, crash_identifiers):
37 return cls._CreateKey(channel, platform, signature).get() 32 return cls._CreateKey(crash_identifiers).get()
38 33
39 @classmethod 34 @classmethod
40 def Create(cls, channel, platform, signature): 35 def Create(cls, crash_identifiers):
41 analysis = cls(key=cls._CreateKey(channel, platform, signature)) 36 analysis = cls(key=cls._CreateKey(crash_identifiers))
42 analysis.signature = signature
43 return analysis 37 return analysis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698