Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from google.appengine.ext import ndb | |
| 6 | |
| 7 from model.base_build_model import BaseBuildModel | |
| 8 from model.wf_suspected_cl import WfSuspectedCL | |
| 9 | |
| 10 | |
| 11 def GetCLInfo(cl_info_str): | |
|
stgao
2016/09/28 00:13:27
Can we have docstring for this?
chanli
2016/09/30 20:41:01
Done.
| |
| 12 return cl_info_str.split('/') | |
| 13 | |
| 14 | |
| 15 def _GetsStatusFromSameFailure(builds, failures): | |
| 16 for build in builds.values(): | |
| 17 if build['status'] is not None and build['failures'] == failures: | |
| 18 return build['status'] | |
| 19 return None | |
| 20 | |
| 21 | |
| 22 @ndb.transactional | |
| 23 def UpdateSuspectedCL( | |
| 24 repo_name, revision, commit_position, | |
| 25 approach, master_name, builder_name, build_number, cl_failure_type, | |
| 26 failures, top_score): | |
| 27 | |
| 28 suspected_cl = ( | |
| 29 WfSuspectedCL.Get(repo_name, revision) or | |
| 30 WfSuspectedCL.Create(repo_name, revision, commit_position)) | |
| 31 | |
| 32 if approach not in suspected_cl.approaches: | |
| 33 suspected_cl.approaches.append(approach) | |
| 34 if cl_failure_type not in suspected_cl.failure_type: | |
| 35 suspected_cl.failure_type.append(cl_failure_type) | |
| 36 | |
| 37 build_key = BaseBuildModel.CreateBuildId( | |
| 38 master_name, builder_name, build_number) | |
| 39 if build_key not in suspected_cl.builds: | |
| 40 suspected_cl.builds[build_key] = { | |
| 41 'approaches': [approach], | |
| 42 'failure_type': cl_failure_type, | |
| 43 'failures': failures, | |
| 44 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures), | |
| 45 'top_score': top_score | |
| 46 } | |
| 47 else: | |
| 48 build = suspected_cl.builds[build_key] | |
| 49 if approach not in build['approaches']: | |
| 50 build['approaches'].append(approach) | |
| 51 | |
| 52 suspected_cl.put() | |
| OLD | NEW |