@@ -19,3 +19,10 @@ def post_data(field, keys, value):
print(data, "failed!!")
except Exception as e:
pass
+
+if __name__ == '__main__':
+ from db import db
+ errors = db().get_sources_with_error()
+ for e in errors:
+ post_data('error', {'source': e['_id']}, e['count'])
@@ -184,3 +184,7 @@ class db():
print(res)
self.c_articles.update({"_id": ObjectId(a["_id"])}, {"$set": res})
#matches, kw, weight
+ def get_sources_with_error(self):
+ self.c_articles.aggregate([{'$match': {'error': True}},
+ {'$group': {'_id': '$source_name', 'count': {'$sum': 1}}}])