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

Unified Diff: dashboard/dashboard/models/histogram.py

Issue 2977283002: Ownership into GenericSets (Closed)
Patch Set: Fix tests after reabse Created 3 years, 5 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 | « dashboard/dashboard/find_anomalies_test.py ('k') | dashboard/dashboard/models/histogram_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/models/histogram.py
diff --git a/dashboard/dashboard/models/histogram.py b/dashboard/dashboard/models/histogram.py
index 6422907bb9ee3e864f65f611df27663b62503d53..ae81d148a5d7744522b9fa1c4e0dfdedeb2b2d01 100644
--- a/dashboard/dashboard/models/histogram.py
+++ b/dashboard/dashboard/models/histogram.py
@@ -4,6 +4,9 @@
"""The datastore models for histograms and diagnostics."""
+import json
+import sys
+
from google.appengine.ext import ndb
from dashboard.models import graph_data
@@ -27,5 +30,33 @@ class Histogram(JsonModel):
class SparseDiagnostic(JsonModel):
# Need for intersecting range queries.
+ name = ndb.StringProperty(indexed=False)
start_revision = ndb.IntegerProperty(indexed=True)
end_revision = ndb.IntegerProperty(indexed=True)
+
+ @staticmethod
+ def GetMostRecentValuesByNames(test_key, diagnostic_names):
+ """Gets the data in the latests sparse diagnostics with the given
+ set of diagnostic names.
+
+ Args:
+ test_key: The TestKey entity to lookup the diagnotics by
+ diagnostic_names: Set of the names of the diagnostics to look up
+
+ Returns:
+ A dictionary where the keys are the given names, and the values are the
+ corresponding diagnostics' values.
+ None if no diagnostics are found with the given keys or type.
+ """
+ diagnostics = SparseDiagnostic.query(
+ ndb.AND(SparseDiagnostic.end_revision == sys.maxint,
+ SparseDiagnostic.test == test_key)).fetch()
+
+ diagnostic_map = {}
+
+ for diagnostic in diagnostics:
+ if diagnostic.name in diagnostic_names:
+ assert diagnostic_map.get(diagnostic.name) is None
+ diagnostic_data = json.loads(diagnostic.data)
+ diagnostic_map[diagnostic.name] = diagnostic_data.get('values')
+ return diagnostic_map
« no previous file with comments | « dashboard/dashboard/find_anomalies_test.py ('k') | dashboard/dashboard/models/histogram_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698