Beispiel #1
0
def aggregate(window=24, *args):
  if "force" in args:
    nuke_it()

  window = int(window)
  with timer():
    map_data(_aggregate, window)
Beispiel #2
0
def top_crashes(top=10, start="", end="", *args):
  start, end = parse_start_end(start, end)
  top = int(top)

  if "force" in args or not r.exists(top_crashes_key(start, end)):
    r.delete(top_crashes_key(start, end))
    with timer():
      map_data(_top_crashes, start, end, start=datetime.strptime(start, "%Y%m%d"), end=datetime.strptime(end, "%Y%m%d"))

  with timer():
    for i in sorted(r.hgetall(top_crashes_key(start, end)).items(), key=lambda x: int(x[1]), reverse=True)[:top]:
      print i