|
|
@@ -189,3 +189,15 @@ class db():
|
|
|
r = self.c_articles.aggregate([{'$match': {'error': True}},
|
|
|
{'$group': {'_id': '$source_name', 'count': {'$sum': 1}}}])
|
|
|
return r
|
|
|
+
|
|
|
+ def get_sources_with_count(self):
|
|
|
+ r = self.c_articles.aggregate([{'$match': {'matches': True}},
|
|
|
+ {'$group':
|
|
|
+ {'_id': '$source_name',
|
|
|
+ 'count': {'$sum': 1},
|
|
|
+ 'weight': {'$avg': '$weight'}
|
|
|
+ }
|
|
|
+ }])
|
|
|
+
|
|
|
+ # t = self.c_articles.aggregate([{'$group': {'_id': '$source_name', 'count': {'$sum': 1}}}])
|
|
|
+ return r
|