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

Side by Side Diff: appengine/findit/model/base_triaged_model.py

Issue 2416303002: [Findit] Adding support for triaging suspected builds from flake analysis (Closed)
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
« no previous file with comments | « appengine/findit/main.py ('k') | appengine/findit/model/flake/master_flake_analysis.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 appengine_util
8 from common import time_util
9 from model import triage_status
10
11
12 class TriageResult(ndb.Model):
13 # The user who updated this result.
14 user_name = ndb.StringProperty(default=None, indexed=False)
15
16 # The time this triage result was determined.
17 triaged_time = ndb.DateTimeProperty(indexed=False, auto_now=True)
18
19 # The result of the analysis as correct or not. If not triaged, the value
20 # should be None. Other traige result codes are up to the child class to set.
21 triage_result = ndb.IntegerProperty(default=None, indexed=True)
22
23 # The version of findit that generated this result. Should primarily be
24 # relevant for entities that are not versioned.
25 findit_version = ndb.StringProperty(default=None, indexed=False)
26
27 # The version number of the entity that is being triaged. Should primarily be
28 # relevant for versioned entites.
29 version_number = ndb.IntegerProperty(default=None, indexed=False)
30
31 # Other information about this result. For example, cl_info for suspected CLs
32 # which may contain repo/revision or the suspected range for a flake analysis.
33 suspect_info = ndb.JsonProperty(default=None, indexed=False)
34
35
36 class TriagedModel(ndb.Model):
37 """The parent class for models that can have traige results."""
38
39 def UpdateTriageResult(self, triage_result, suspect_info, user_name,
40 version_number=None):
41 result = TriageResult()
42 result.user_name = user_name
43 result.triage_result = triage_result
44 result.findit_version = appengine_util.GetCurrentVersion()
45 result.version_number = version_number
46 result.suspect_info = suspect_info
47 self.triage_history.append(result)
48
49 def GetTriageHistory(self):
50 # Gets the triage history of a triaged model as a list of dicts.
51 triage_history = []
52 for triage_record in self.triage_history:
53 triage_history.append({
54 'triaged_time': time_util.FormatDatetime(triage_record.triaged_time),
55 'user_name': triage_record.user_name,
56 'suspect_info': triage_record.suspect_info,
57 'triage_result': (
58 triage_status.TRIAGE_STATUS_TO_DESCRIPTION.get(
59 triage_record.triage_result)),
60 'findit_version': triage_record.findit_version,
61 'version_number': triage_record.version_number
62 })
63
64 return triage_history
65
66 # Record the triage result history.
67 triage_history = ndb.LocalStructuredProperty(
68 TriageResult, repeated=True, indexed=False, compressed=True)
OLDNEW
« no previous file with comments | « appengine/findit/main.py ('k') | appengine/findit/model/flake/master_flake_analysis.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698