diff options
author | cedricbonhomme <devnull@localhost> | 2012-03-04 09:47:56 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2012-03-04 09:47:56 +0100 |
commit | 6278d00ed760cd216067dd7977ab874c1d42bb49 (patch) | |
tree | 02a3b8cabb22f0fc978bedde480947ec7974a698 /mongodb.py | |
parent | Unread articles page is now completely working. Improvements of the get_artic... (diff) | |
download | newspipe-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.py | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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: |