| 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 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 analysis.triage_reference_analysis_build_number = ( | 177 analysis.triage_reference_analysis_build_number = ( |
| 178 original_analysis.build_number) | 178 original_analysis.build_number) |
| 179 _AppendTriageHistoryRecord(analysis, is_correct, user_name, | 179 _AppendTriageHistoryRecord(analysis, is_correct, user_name, |
| 180 is_duplicate=True) | 180 is_duplicate=True) |
| 181 | 181 |
| 182 return len(matching_analyses) | 182 return len(matching_analyses) |
| 183 | 183 |
| 184 | 184 |
| 185 class TriageAnalysis(BaseHandler): | 185 class TriageAnalysis(BaseHandler): |
| 186 PERMISSION_LEVEL = Permission.CORP_USER | 186 PERMISSION_LEVEL = Permission.CORP_USER |
| 187 LOGIN_REDIRECT_TO_DISTINATION_PAGE_FOR_GET = False |
| 187 | 188 |
| 188 def HandleGet(self): # pragma: no cover | 189 def HandleGet(self): # pragma: no cover |
| 189 return self.HandlePost() | 190 return self.HandlePost() |
| 190 | 191 |
| 191 def HandlePost(self): | 192 def HandlePost(self): |
| 192 """Sets the manual triage result for the analysis. | 193 """Sets the manual triage result for the analysis. |
| 193 | 194 |
| 194 Mark the analysis result as correct/wrong/etc. | 195 Mark the analysis result as correct/wrong/etc. |
| 195 TODO: make it possible to set the real culprit CLs. | 196 TODO: make it possible to set the real culprit CLs. |
| 196 """ | 197 """ |
| 197 url = self.request.get('url').strip() | 198 url = self.request.get('url').strip() |
| 198 build_info = buildbot.ParseBuildUrl(url) | 199 build_info = buildbot.ParseBuildUrl(url) |
| 199 if not build_info: | 200 if not build_info: |
| 200 return {'data': {'success': False}} | 201 return {'data': {'success': False}} |
| 201 master_name, builder_name, build_number = build_info | 202 master_name, builder_name, build_number = build_info |
| 202 | 203 |
| 203 is_correct = self.request.get('correct').lower() == 'true' | 204 is_correct = self.request.get('correct').lower() == 'true' |
| 204 # As the permission level is CORP_USER, we could assume the current user | 205 # As the permission level is CORP_USER, we could assume the current user |
| 205 # already logged in. | 206 # already logged in. |
| 206 user_name = users.get_current_user().email().split('@')[0] | 207 user_name = users.get_current_user().email().split('@')[0] |
| 207 success, original_analysis = _UpdateAnalysisResultStatus( | 208 success, original_analysis = _UpdateAnalysisResultStatus( |
| 208 master_name, builder_name, build_number, is_correct, user_name) | 209 master_name, builder_name, build_number, is_correct, user_name) |
| 209 num_duplicate_analyses = 0 | 210 num_duplicate_analyses = 0 |
| 210 if success: | 211 if success: |
| 211 num_duplicate_analyses = _TriageAndCountDuplicateResults( | 212 num_duplicate_analyses = _TriageAndCountDuplicateResults( |
| 212 original_analysis, is_correct, user_name) | 213 original_analysis, is_correct, user_name) |
| 213 return {'data': {'success': success, | 214 return {'data': {'success': success, |
| 214 'num_duplicate_analyses': num_duplicate_analyses}} | 215 'num_duplicate_analyses': num_duplicate_analyses}} |
| OLD | NEW |