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 common.waterfall import failure_type | |
| 8 from model import analysis_approach_type | |
| 9 from model.wf_suspected_cl import WfSuspectedCL | |
| 10 | |
| 11 def _GetsStatusFromSameFailure(builds, failures): | |
| 12 for build in builds.values(): | |
| 13 if build['status'] is not None and build['failures'] == failures: | |
| 14 return build['status'] | |
| 15 return None | |
| 16 | |
| 17 | |
| 18 @ndb.transactional | |
| 19 def UpdateSuspectedCL( | |
| 20 repo_name, revision, commit_position, | |
| 21 approach, master_name, builder_name, build_number, cl_failure_type, | |
| 22 failures, top_score): | |
| 23 | |
| 24 suspected_cl = ( | |
| 25 WfSuspectedCL.Get(repo_name, revision) or | |
| 26 WfSuspectedCL.Create(repo_name, revision, commit_position)) | |
| 27 | |
| 28 if approach not in suspected_cl.approaches: | |
| 29 suspected_cl.approaches.append(approach) | |
| 30 if cl_failure_type not in suspected_cl.failure_type: | |
| 31 suspected_cl.failure_type.append(cl_failure_type) | |
| 32 | |
| 33 build_key = '%s/%s/%d' %(master_name, builder_name, build_number) | |
|
stgao
2016/09/23 18:56:54
Can we extract this logic to some place to share w
chanli
2016/09/24 00:05:00
Done.
| |
| 34 if build_key not in suspected_cl.builds: | |
| 35 build = { | |
| 36 'approaches': [approach], | |
| 37 'failure_type': cl_failure_type, | |
| 38 'failures': failures, | |
| 39 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures), | |
| 40 'top_score': top_score | |
| 41 } | |
| 42 suspected_cl.builds[build_key] = build | |
|
stgao
2016/09/23 18:30:21
Inline it in #35?
chanli
2016/09/24 00:05:00
Done.
| |
| 43 else: | |
| 44 build = suspected_cl.builds[build_key] | |
| 45 build['approaches'].append(approach) | |
|
stgao
2016/09/23 18:30:21
What if the approach is already in the list?
chanli
2016/09/24 00:05:00
This is for a specific build, so logically the app
| |
| 46 | |
| 47 suspected_cl.put() | |
| OLD | NEW |