Skip to content

Instantly share code, notes, and snippets.

@mhammond
Last active January 31, 2017 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhammond/c9a9a928e7634bdd9a586aac6bcc8732 to your computer and use it in GitHub Desktop.
Save mhammond/c9a9a928e7634bdd9a586aac6bcc8732 to your computer and use it in GitHub Desktop.
Max validation errors
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# 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