Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: appengine/findit/waterfall/suspected_cl_util.py

Issue 2230103002: [Findit] Pipeline change to save suspected cls to data store. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0808-resubmit-suspected_cl_model
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 import time_util
8 from model.base_build_model import BaseBuildModel
9 from model.wf_suspected_cl import WfSuspectedCL
10
11
12 def GetCLInfo(cl_info_str):
13 """Gets CL's repo_name and revision."""
14 return cl_info_str.split('/')
15
16
17 def _GetsStatusFromSameFailure(builds, failures):
18 for build in builds.values():
19 if build['status'] is not None and build['failures'] == failures:
20 return build['status']
21 return None
22
23
24 @ndb.transactional
25 def UpdateSuspectedCL(
26 repo_name, revision, commit_position,
27 approach, master_name, builder_name, build_number, cl_failure_type,
28 failures, top_score):
29
30 suspected_cl = (
31 WfSuspectedCL.Get(repo_name, revision) or
32 WfSuspectedCL.Create(repo_name, revision, commit_position))
33
34 if not suspected_cl.identified_time: # pragma: no cover.
35 suspected_cl.identified_time = time_util.GetUTCNow()
36
37 suspected_cl.updated_time = time_util.GetUTCNow()
38
39 if approach not in suspected_cl.approaches:
40 suspected_cl.approaches.append(approach)
41 if cl_failure_type not in suspected_cl.failure_type:
42 suspected_cl.failure_type.append(cl_failure_type)
43
44 build_key = BaseBuildModel.CreateBuildId(
45 master_name, builder_name, build_number)
46 if build_key not in suspected_cl.builds:
47 suspected_cl.builds[build_key] = {
48 'approaches': [approach],
49 'failure_type': cl_failure_type,
50 'failures': failures,
51 'status': _GetsStatusFromSameFailure(suspected_cl.builds, failures),
52 'top_score': top_score
53 }
54 else:
55 build = suspected_cl.builds[build_key]
56 if approach not in build['approaches']:
57 build['approaches'].append(approach)
58
59 suspected_cl.put()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698