| Index: appengine/findit/handlers/crash/fracas_result_feedback.py
|
| diff --git a/appengine/findit/handlers/crash/fracas_result_feedback.py b/appengine/findit/handlers/crash/fracas_result_feedback.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7f9473feaee66ed3bc71d8ee951494f4235aea78
|
| --- /dev/null
|
| +++ b/appengine/findit/handlers/crash/fracas_result_feedback.py
|
| @@ -0,0 +1,109 @@
|
| +# Copyright 2014 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 base64
|
| +from collections import defaultdict
|
| +import copy
|
| +from datetime import datetime
|
| +import json
|
| +import os
|
| +
|
| +from google.appengine.ext import ndb
|
| +from google.appengine.api import users
|
| +
|
| +from common import constants
|
| +from common import time_util
|
| +from common.base_handler import BaseHandler
|
| +from common.base_handler import Permission
|
| +from handlers import handlers_util
|
| +from handlers import result_status
|
| +from handlers.result_status import NO_TRY_JOB_REASON_MAP
|
| +from model.crash.fracas_crash_analysis import FracasCrashAnalysis
|
| +from model import triage_status
|
| +
|
| +
|
| +def _GetTriageHistory(analysis):
|
| + if (not users.is_current_user_admin() or
|
| + not analysis.completed or
|
| + not analysis.triage_history):
|
| + return None
|
| +
|
| + triage_history = []
|
| + for triage_record in analysis.triage_history:
|
| + triage_history.append({
|
| + 'triage_time': time_util.FormatDatetime(
|
| + datetime.utcfromtimestamp(triage_record['triage_timestamp'])),
|
| + 'result_property': triage_record['result_property'],
|
| + 'user_name': triage_record['user_name'],
|
| + 'triage_status': triage_record['triage_status']
|
| + })
|
| +
|
| + return triage_history
|
| +
|
| +
|
| +class FracasResultFeedback(BaseHandler):
|
| + PERMISSION_LEVEL = Permission.ANYONE
|
| +
|
| + def _GetCrashDataFromAnalysis(self, analysis):
|
| + print analysis.culprit_cls
|
| + return {
|
| + 'signature': analysis.signature,
|
| + 'version': analysis.crashed_version,
|
| + 'channel': analysis.channel,
|
| + 'platform': analysis.platform,
|
| + 'regression_range': (
|
| + analysis.result['regression_range'] if 'regression_range' in
|
| + analysis.result else None),
|
| + 'culprit_regression_range': analysis.culprit_regression_range,
|
| + 'historical_metadata': analysis.historical_metadata,
|
| + 'stack_trace': analysis.stack_trace,
|
| + 'suspected_cls': (
|
| + analysis.result['suspected_cls'] if 'suspected_cls' in
|
| + analysis.result else None),
|
| + 'culprit_cls': analysis.culprit_cls,
|
| + 'suspected_project': (
|
| + analysis.result['suspected_project'] if 'suspected_project' in
|
| + analysis.result else None),
|
| + 'culprit_project': analysis.culprit_project,
|
| + 'suspected_components': (
|
| + analysis.result['suspected_components'] if 'suspected_components'
|
| + in analysis.result else None),
|
| + 'culprit_components': analysis.culprit_components,
|
| + 'request_time': time_util.FormatDatetime(analysis.requested_time),
|
| + 'triage_history': _GetTriageHistory(analysis),
|
| + 'analysis_completed': analysis.completed,
|
| + 'analysis_failed': analysis.failed,
|
| + 'analysis_correct': {
|
| + 'regression_range': analysis.regression_range_triage_status,
|
| + 'suspected_cls': analysis.suspected_cls_triage_status,
|
| + 'suspected_project': analysis.suspected_project_triage_status,
|
| + 'suspected_components': analysis.suspected_components_triage_status,
|
| + },
|
| + 'note': analysis.note,
|
| + 'key': self.request.get('key'),
|
| + }
|
| +
|
| + def HandleGet(self):
|
| + """Triggers analysis of a build failure on demand and return current result.
|
| +
|
| + If the final analysis result is available, set cache-control to 1 day to
|
| + avoid overload by unnecessary and frequent query from clients; otherwise
|
| + set cache-control to 5 seconds to allow repeated query.
|
| +
|
| + Serve HTML page or JSON result as requested.
|
| + """
|
| + key = ndb.Key(urlsafe=self.request.get('key'))
|
| +
|
| + analysis = key.get()
|
| + if not analysis: # pragma: no cover.
|
| + return BaseHandler.CreateError(
|
| + 'cannot find analysis for crash %s' % analysis.signature)
|
| +
|
| + return {
|
| + 'template': 'crash/fracas_result_feedback.html',
|
| + 'data': self._GetCrashDataFromAnalysis(analysis),
|
| + }
|
| +
|
| + def HandlePost(self): # pragma: no cover
|
| + return self.HandleGet()
|
|
|