aboutsummaryrefslogtreecommitdiff
path: root/mongodb.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-03-04 09:47:56 +0100
committercedricbonhomme <devnull@localhost>2012-03-04 09:47:56 +0100
commit6278d00ed760cd216067dd7977ab874c1d42bb49 (patch)
tree02a3b8cabb22f0fc978bedde480947ec7974a698 /mongodb.py
parentUnread articles page is now completely working. Improvements of the get_artic... (diff)
downloadnewspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.tar.gz
newspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.tar.bz2
newspipe-6278d00ed760cd216067dd7977ab874c1d42bb49.zip
Mamangement page is now almost workink.
Diffstat (limited to 'mongodb.py')
-rw-r--r--mongodb.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/mongodb.py b/mongodb.py
index 1f74d164..8c1cc59d 100644
--- a/mongodb.py
+++ b/mongodb.py
@@ -108,13 +108,35 @@ class Articles(object):
"""
if feed_id is not None:
collection = self.db[feed_id]
- return collection.find({"type":1}).count()
+ cursor = collection.find({'type':1})
+ return cursor.count()
+ else:
+ nb_articles = 0
+ for feed_id in self.db.collection_names():
+ nb_articles += self.nb_articles(feed_id)
+ return nb_articles
- def nb_favorites(self):
- return "12"
+ def nb_favorites(self, feed_id=None):
+ if feed_id is not None:
+ collection = self.db[feed_id]
+ cursor = collection.find({'type':1, 'article_like':True})
+ return cursor.count()
+ else:
+ nb_favorites = 0
+ for feed_id in self.db.collection_names():
+ nb_favorites += self.nb_favorites(feed_id)
+ return nb_favorites
def nb_mail_notifications(self):
- return "42"
+ """
+ Return the number of subscribed feeds.
+ """
+ nb_mail_notifications = 0
+ for feed_id in self.db.collection_names():
+ collection = self.db[feed_id]
+ cursor = collection.find({'type':0, 'mail':True})
+ nb_mail_notifications += cursor.count()
+ return nb_mail_notifications
def nb_unread_articles(self, feed_id=None):
if feed_id is not None:
bgstack15