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

Side by Side Diff: appengine/findit/handlers/crash/triage_fracas_analysis.py

Issue 2074273002: [Findit] Add feedback button for manual triage. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@show-result
Patch Set: Created 4 years, 5 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
(Empty)
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
3 # found in the LICENSE file.
4
5 """This module is to handle manual triage of fracas crash analysis result."""
6
7 import calendar
8 from datetime import datetime
9 import json
10
11 from google.appengine.api import users
12 from google.appengine.ext import ndb
13
14 from common.base_handler import BaseHandler
15 from common.base_handler import Permission
16 from model import triage_status
17 from model.crash.fracas_crash_analysis import FracasCrashAnalysis
18
19
20 @ndb.transactional
21 def _UpdateAnalysis(key, user_name, update):
stgao 2016/06/30 01:28:02 Var name `update` is not clear.
Sharu Jiang 2016/07/01 22:05:48 Changed to update_data.
22 analysis = key.get()
23 success = analysis.Update(update)
24
25 result_property = None
26 status = None
27 for key, value in update.iteritems():
28 if 'triage_status' in key:
stgao 2016/06/30 01:28:02 Will there be multiple 'triage_status'?
Sharu Jiang 2016/07/01 22:05:48 We only click one button at a time, so it will onl
29 result_property = key.replace('_triage_status', '')
30 status = value
31 break
32
33 if not result_property:
34 analysis.put()
35 return success
36
37 triage_record = {
38 'triage_timestamp': calendar.timegm(datetime.utcnow().timetuple()),
39 'user_name': user_name,
40 'result_property': result_property,
41 'triage_status': triage_status.TRIAGE_STATUS_TO_DESCRIPTION[status],
stgao 2016/06/30 01:28:02 I guess we won't change the description for a stat
Sharu Jiang 2016/07/01 22:05:48 Acknowledged.
42 }
43
44 if not analysis.triage_history:
45 analysis.triage_history = []
46
47 analysis.triage_history.append(triage_record)
48
49 analysis.put()
50 return success
51
52
53 class TriageFracasAnalysis(BaseHandler):
54 PERMISSION_LEVEL = Permission.CORP_USER
55
56 def HandleGet(self): # pragma: no cover
stgao 2016/06/30 01:28:02 This could be removed if the JS is a post.
Sharu Jiang 2016/07/01 22:05:48 Done.
57 return self.HandlePost()
58
59 def HandlePost(self):
60 """Sets the manual triage result for fracas analysis."""
61 key = ndb.Key(urlsafe=self.request.get('key'))
62 update = self.request.get('update')
63 if not update:
64 return {'data': {'success': False}}
65
66 update = json.loads(update)
67 # As the permission level is CORP_USER, we could assume the current user
68 # already logged in.
69 user_name = users.get_current_user().email().split('@')[0]
70 success = _UpdateAnalysis(key, user_name, update)
71
72 return {'data': {'success': success}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698