| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """This module is to handle manual triage of analysis result. | 5 """This module is to handle manual triage of analysis result. |
| 6 | 6 |
| 7 This handler will flag the analysis result as correct or incorrect. | 7 This handler will flag the analysis result as correct or incorrect. |
| 8 TODO: work on an automatic or semi-automatic way to triage analysis result. | 8 TODO: work on an automatic or semi-automatic way to triage analysis result. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import calendar | 11 import calendar |
| 12 from datetime import datetime | 12 from datetime import datetime |
| 13 | 13 |
| 14 from google.appengine.api import users | 14 from google.appengine.api import users |
| 15 from google.appengine.ext import ndb | 15 from google.appengine.ext import ndb |
| 16 | 16 |
| 17 from base_handler import BaseHandler | 17 from base_handler import BaseHandler |
| 18 from base_handler import Permission | 18 from base_handler import Permission |
| 19 from model.wf_analysis import WfAnalysis | 19 from model.wf_analysis import WfAnalysis |
| 20 from model import wf_analysis_result_status | 20 from model import result_status |
| 21 from waterfall import buildbot | 21 from waterfall import buildbot |
| 22 | 22 |
| 23 | 23 |
| 24 @ndb.transactional | 24 @ndb.transactional |
| 25 def _UpdateAnalysisResultStatus( | 25 def _UpdateAnalysisResultStatus( |
| 26 master_name, builder_name, build_number, correct, user_name=None): | 26 master_name, builder_name, build_number, correct, user_name=None): |
| 27 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 27 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 28 if not analysis or not analysis.completed: | 28 if not analysis or not analysis.completed: |
| 29 return False | 29 return False |
| 30 | 30 |
| 31 if correct: | 31 if correct: |
| 32 if analysis.suspected_cls: | 32 if analysis.suspected_cls: |
| 33 analysis.result_status = wf_analysis_result_status.FOUND_CORRECT | 33 analysis.result_status = result_status.FOUND_CORRECT |
| 34 analysis.culprit_cls = analysis.suspected_cls | 34 analysis.culprit_cls = analysis.suspected_cls |
| 35 else: | 35 else: |
| 36 analysis.result_status = wf_analysis_result_status.NOT_FOUND_CORRECT | 36 analysis.result_status = result_status.NOT_FOUND_CORRECT |
| 37 analysis.culprit_cls = None | 37 analysis.culprit_cls = None |
| 38 else: | 38 else: |
| 39 analysis.culprit_cls = None | 39 analysis.culprit_cls = None |
| 40 if analysis.suspected_cls: | 40 if analysis.suspected_cls: |
| 41 analysis.result_status = wf_analysis_result_status.FOUND_INCORRECT | 41 analysis.result_status = result_status.FOUND_INCORRECT |
| 42 else: | 42 else: |
| 43 analysis.result_status = wf_analysis_result_status.NOT_FOUND_INCORRECT | 43 analysis.result_status = result_status.NOT_FOUND_INCORRECT |
| 44 | 44 |
| 45 triage_record = { | 45 triage_record = { |
| 46 'triage_timestamp': calendar.timegm(datetime.utcnow().timetuple()), | 46 'triage_timestamp': calendar.timegm(datetime.utcnow().timetuple()), |
| 47 'user_name': user_name, | 47 'user_name': user_name, |
| 48 'result_status': analysis.result_status, | 48 'result_status': analysis.result_status, |
| 49 'version': analysis.version, | 49 'version': analysis.version, |
| 50 } | 50 } |
| 51 if not analysis.triage_history: | 51 if not analysis.triage_history: |
| 52 analysis.triage_history = [] | 52 analysis.triage_history = [] |
| 53 analysis.triage_history.append(triage_record) | 53 analysis.triage_history.append(triage_record) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 74 return {'data': {'success': False}} | 74 return {'data': {'success': False}} |
| 75 master_name, builder_name, build_number = build_info | 75 master_name, builder_name, build_number = build_info |
| 76 | 76 |
| 77 correct = self.request.get('correct').lower() == 'true' | 77 correct = self.request.get('correct').lower() == 'true' |
| 78 # As the permission level is CORP_USER, we could assume the current user | 78 # As the permission level is CORP_USER, we could assume the current user |
| 79 # already logged in. | 79 # already logged in. |
| 80 user_name = users.get_current_user().email().split('@')[0] | 80 user_name = users.get_current_user().email().split('@')[0] |
| 81 success = _UpdateAnalysisResultStatus( | 81 success = _UpdateAnalysisResultStatus( |
| 82 master_name, builder_name, build_number, correct, user_name) | 82 master_name, builder_name, build_number, correct, user_name) |
| 83 return {'data': {'success': success}} | 83 return {'data': {'success': success}} |
| OLD | NEW |