-
-
Save mhammond/c9a9a928e7634bdd9a586aac6bcc8732 to your computer and use it in GitHub Desktop.
Max validation errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
from moztelemetry import get_pings, get_pings_properties | |
# filter the ones we care about early... | |
def filterOurs(ping): | |
try: | |
syncs = ping["payload"]["syncs"] | |
except KeyError: | |
return False | |
for sync in syncs: | |
for engine in sync.get("engines", []): | |
if "name" in engine and engine["name"] == "bookmarks" and "validation" in engine and "problems" in engine["validation"]: | |
return True | |
return False | |
pings = get_pings(sc, doc_type='sync', fraction=1.0).filter(filterOurs) | |
# In[2]: | |
def flattenBookmarkValidations(ping): | |
result = [] | |
for sync in ping["payload"]["syncs"]: | |
for engine in sync.get("engines", []): | |
if "validation" in engine: | |
# turn it into a dict. | |
this = {} | |
for problem in engine["validation"]["problems"]: | |
this[problem["name"]] = problem["count"] | |
result.append(this) | |
return result | |
# And reduce each one into the max | |
def reduceToMax(a, b): | |
allKeys = set(a.keys()) | |
allKeys.update(b.keys()) | |
result = {} | |
for key in allKeys: | |
result[key] = max(a.get(key, 0), b.get(key, 0)) | |
return result | |
pings.flatMap(flattenBookmarkValidations).reduce(reduceToMax) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment