| 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 import analysis_approach_type |
| 8 from model.wf_suspected_cl import WfSuspectedCL |
| 9 |
| 10 def _GetsStatusFromSameFailure(builds, failures): |
| 11 for build in builds.values(): |
| 12 if build['status'] is not None and build['failures'] == failures: |
| 13 return build['status'] |
| 14 return None |
| 15 |
| 16 |
| 17 @ndb.transactional |
| 18 def UpdateSuspectedCL( |
| 19 repo_name, revision, commit_position, |
| 20 approach, master_name, builder_name, build_number, failure_type, |
| 21 failures, top_score): |
| 22 |
| 23 suspected_cl = ( |
| 24 WfSuspectedCL.Get(repo_name, revision) or |
| 25 WfSuspectedCL.Create(repo_name, revision, commit_position)) |
| 26 |
| 27 # HEURISTIC: 1; TRY_JOB: 2; BOTH: 3. |
| 28 suspected_cl.approach = ( |
| 29 suspected_cl.approach | approach if suspected_cl.approach and |
| 30 suspected_cl.approach != approach else approach) |
| 31 suspected_cl.failure_type = suspected_cl.failure_type or failure_type |
| 32 |
| 33 build_key = '%s/%s/%d' %(master_name, builder_name, build_number) |
| 34 if build_key not in suspected_cl.builds: |
| 35 build = { |
| 36 'approach': approach, |
| 37 'failure_type': 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 |
| 43 else: |
| 44 build = suspected_cl.builds[build_key] |
| 45 build['approach'] = ( |
| 46 build['approach'] | approach if build['approach'] else approach) |
| 47 |
| 48 |
| 49 suspected_cl.put() |
| OLD | NEW |