Chromium Code Reviews| Index: appengine/findit/model/flake/flake_analysis_request.py |
| diff --git a/appengine/findit/model/flake/flake_analysis_request.py b/appengine/findit/model/flake/flake_analysis_request.py |
| index ccef2c153f1b39f22a12cc4501d3130f02b0c85f..ddf30d529efa9b3cc5fc6fb5df15652c06470d95 100644 |
| --- a/appengine/findit/model/flake/flake_analysis_request.py |
| +++ b/appengine/findit/model/flake/flake_analysis_request.py |
| @@ -2,6 +2,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import logging |
| + |
| from google.appengine.ext import ndb |
| from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| @@ -128,3 +130,31 @@ class FlakeAnalysisRequest(VersionedModel): |
| self.user_emails = other.user_emails |
| self.build_steps = other.build_steps |
| self.analyses = other.analyses |
| + |
| + def _GetNormalizedConfigurationNames(self, master_name, builder_name): |
| + for build_step in self.build_steps: |
| + if ((build_step.master_name == master_name and |
| + build_step.builder_name == builder_name) or |
| + (build_step.wf_master_name == master_name and |
| + build_step.wf_builder_name == builder_name)): |
| + return build_step.wf_master_name, build_step.wf_builder_name |
| + return None, None |
| + |
| + def FindMatchingAnalysisForConfiguration(self, master_name, builder_name): |
| + normalized_master_name, normalized_builder_name = ( |
| + self._GetNormalizedConfigurationNames(master_name, builder_name)) |
| + |
| + if not normalized_builder_name or not normalized_master_name: |
| + return None |
| + |
| + for analysis_key in self.analyses: |
| + analysis = analysis_key.get() |
|
stgao
2016/11/18 17:33:42
Based on the key, we could derive master/builder n
lijeffrey
2016/11/18 20:47:33
Done.
|
| + |
| + if not analysis: # pragma: no cover |
| + logging.error('Analysis was deleted unexpectedly!') |
| + return None |
|
chanli
2016/11/18 19:15:28
If one analysis is deleted, I agree we should log
lijeffrey
2016/11/18 20:47:33
Done.
|
| + if (analysis.master_name == normalized_master_name and |
| + analysis.builder_name == normalized_builder_name): |
| + return analysis |
| + |
| + return None |