Bläddra i källkod

push total analytics to influx

David 9 år sedan
förälder
incheckning
7c7157e8ff
1 ändrade filer med 4 tillägg och 2 borttagningar
  1. 4 2
      analytics.py

+ 4 - 2
analytics.py

@@ -23,11 +23,13 @@ def post_data(field, keys, value):
 
 if __name__ == '__main__':
     from db import db
-    from pprint import pprint
     d = db()
     errors = d.get_sources_with_error()
     for e in errors:
         val = e['_id'].replace(" ", r"\ ")
         post_data('error', {'source': '%s' % val}, e['count'])
 
-    pprint(list(d.get_sources_with_count()))
+    for d in d.get_sources_with_count():
+        val = d['_id'].replace(" ", r"\ ")
+        post_data('totals', {'source': '%s' % val},
+                  '%d,weight=%f' % (d['count'], d['weight']))