| OLD | NEW |
| 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 logging | 5 import logging |
| 6 | 6 |
| 7 from google.appengine.api import users | 7 from google.appengine.api import users |
| 8 from google.appengine.ext import ndb | 8 from google.appengine.ext import ndb |
| 9 | 9 |
| 10 from common.base_handler import BaseHandler | 10 from common.base_handler import BaseHandler |
| 11 from common.base_handler import Permission | 11 from common.base_handler import Permission |
| 12 from gae_libs.http import auth_util | 12 from gae_libs.http import auth_util |
| 13 from libs import time_util | 13 from libs import time_util |
| 14 from model import analysis_status | 14 from model import analysis_status |
| 15 from model import triage_status | 15 from model import triage_status |
| 16 from model.flake.flake_analysis_request import FlakeAnalysisRequest | 16 from model.flake.flake_analysis_request import FlakeAnalysisRequest |
| 17 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 17 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 18 from waterfall.flake import flake_analysis_service | 18 from waterfall.flake import flake_analysis_service |
| 19 from waterfall.flake import triggering_sources | 19 from waterfall.flake import triggering_sources |
| 20 | 20 |
| 21 | 21 |
| 22 def _FindSuspectedFlakeBuildDataPoint(analysis): | |
| 23 for data_point in analysis.data_points: | |
| 24 if data_point.build_number == analysis.suspected_flake_build_number: | |
| 25 return data_point | |
| 26 | |
| 27 return None | |
| 28 | |
| 29 | |
| 30 def _GetSuspectedFlakeInfo(analysis): | 22 def _GetSuspectedFlakeInfo(analysis): |
| 31 """Returns a dict with information about the suspected flake build. | 23 """Returns a dict with information about the suspected flake build. |
| 32 | 24 |
| 33 Args: | 25 Args: |
| 34 analysis (MasterFlakeAnalysis): The master flake analysis the suspected | 26 analysis (MasterFlakeAnalysis): The master flake analysis the suspected |
| 35 flake build is associated with. | 27 flake build is associated with. |
| 36 | 28 |
| 37 Returns: | 29 Returns: |
| 38 A dict in the format: | 30 A dict in the format: |
| 39 { | 31 { |
| 40 'build_number': int, | 32 'build_number': int, |
| 41 'commit_position': int, | 33 'commit_position': int, |
| 42 'git_hash': str, | 34 'git_hash': str, |
| 43 'previous_build_commit_position': int, | 35 'previous_build_commit_position': int, |
| 44 'previous_build_git_hash': str, | 36 'previous_build_git_hash': str, |
| 45 'triage_result': int (correct, incorrect, etc.) | 37 'triage_result': int (correct, incorrect, etc.) |
| 46 } | 38 } |
| 47 """ | 39 """ |
| 48 if analysis.suspected_flake_build_number is None: | 40 if analysis.suspected_flake_build_number is None: |
| 49 return {} | 41 return {} |
| 50 | 42 |
| 51 data_point = _FindSuspectedFlakeBuildDataPoint(analysis) | 43 data_point = analysis.GetDataPointOfSuspectedBuild() |
| 52 assert data_point | 44 assert data_point |
| 53 | 45 |
| 54 return { | 46 return { |
| 55 'build_number': analysis.suspected_flake_build_number, | 47 'build_number': analysis.suspected_flake_build_number, |
| 56 'commit_position': data_point.commit_position, | 48 'commit_position': data_point.commit_position, |
| 57 'git_hash': data_point.git_hash, | 49 'git_hash': data_point.git_hash, |
| 58 'previous_build_commit_position': ( | 50 'previous_build_commit_position': ( |
| 59 data_point.previous_build_commit_position), | 51 data_point.previous_build_commit_position), |
| 60 'previous_build_git_hash': data_point.previous_build_git_hash, | 52 'previous_build_git_hash': data_point.previous_build_git_hash, |
| 61 'triage_result': ( | 53 'triage_result': ( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 data['duration'] = time_util.FormatDuration( | 225 data['duration'] = time_util.FormatDuration( |
| 234 analysis.start_time, | 226 analysis.start_time, |
| 235 analysis.end_time or time_util.GetUTCNow()) | 227 analysis.end_time or time_util.GetUTCNow()) |
| 236 | 228 |
| 237 data['pass_rates'] = _GetCoordinatesData(analysis) | 229 data['pass_rates'] = _GetCoordinatesData(analysis) |
| 238 | 230 |
| 239 return { | 231 return { |
| 240 'template': 'flake/result.html', | 232 'template': 'flake/result.html', |
| 241 'data': data | 233 'data': data |
| 242 } | 234 } |
| OLD | NEW |