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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/model/base_triaged_model.py
diff --git a/appengine/findit/model/base_triaged_model.py b/appengine/findit/model/base_triaged_model.py
new file mode 100644
index 0000000000000000000000000000000000000000..ca008eada110ba8e57cda01315c88faccbc308d8
--- /dev/null
+++ b/appengine/findit/model/base_triaged_model.py
@@ -0,0 +1,68 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from google.appengine.ext import ndb
+
+from common import appengine_util
+from common import time_util
+from model import triage_status
+
+
+class TriageResult(ndb.Model):
+ # The user who updated this result.
+ user_name = ndb.StringProperty(default=None, indexed=False)
+
+ # The time this triage result was determined.
+ triaged_time = ndb.DateTimeProperty(indexed=False, auto_now=True)
+
+ # The result of the analysis as correct or not. If not triaged, the value
+ # should be None. Other traige result codes are up to the child class to set.
+ triage_result = ndb.IntegerProperty(default=None, indexed=True)
+
+ # The version of findit that generated this result. Should primarily be
+ # relevant for entities that are not versioned.
+ findit_version = ndb.StringProperty(default=None, indexed=False)
+
+ # The version number of the entity that is being triaged. Should primarily be
+ # relevant for versioned entites.
+ version_number = ndb.IntegerProperty(default=None, indexed=False)
+
+ # Other information about this result. For example, cl_info for suspected CLs
+ # which may contain repo/revision or the suspected range for a flake analysis.
+ suspect_info = ndb.JsonProperty(default=None, indexed=False)
+
+
+class TriagedModel(ndb.Model):
+ """The parent class for models that can have traige results."""
+
+ def UpdateTriageResult(self, triage_result, suspect_info, user_name,
+ version_number=None):
+ result = TriageResult()
+ result.user_name = user_name
+ result.triage_result = triage_result
+ result.findit_version = appengine_util.GetCurrentVersion()
+ result.version_number = version_number
+ result.suspect_info = suspect_info
+ self.triage_history.append(result)
+
+ def GetTriageHistory(self):
+ # Gets the triage history of a triaged model as a list of dicts.
+ triage_history = []
+ for triage_record in self.triage_history:
+ triage_history.append({
+ 'triaged_time': time_util.FormatDatetime(triage_record.triaged_time),
+ 'user_name': triage_record.user_name,
+ 'suspect_info': triage_record.suspect_info,
+ 'triage_result': (
+ triage_status.TRIAGE_STATUS_TO_DESCRIPTION.get(
+ triage_record.triage_result)),
+ 'findit_version': triage_record.findit_version,
+ 'version_number': triage_record.version_number
+ })
+
+ return triage_history
+
+ # Record the triage result history.
+ triage_history = ndb.LocalStructuredProperty(
+ TriageResult, repeated=True, indexed=False, compressed=True)
« 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