From 3f9e9ff5d9902c0152008ad798ef5d03d47aab84 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 10:41:27 +0100 Subject: Speed improvement in mark_as_read() --- mongodb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mongodb.py') diff --git a/mongodb.py b/mongodb.py index 8c1cc59d..56a83b11 100644 --- a/mongodb.py +++ b/mongodb.py @@ -161,10 +161,10 @@ class Articles(object): """ if feed_id != None and article_id != None: collection = self.db[str(feed_id)] - collection.update({"article_id": article_id}, {"$set": {"article_readed": readed}}) + collection.update({"article_id": article_id, "article_readed":not readed}, {"$set": {"article_readed": readed}}) elif feed_id != None and article_id == None: collection = self.db[str(feed_id)] - collection.update({"type": 1}, {"$set": {"article_readed": readed}}, multi=True) + collection.update({"type": 1, "article_readed":not readed}, {"$set": {"article_readed": readed}}, multi=True) else: for feed_id in self.db.collection_names(): self.mark_as_read(readed, feed_id, None) -- cgit