From 70bdfda0dcb371973a5929bc9bc50593154867a6 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 20 Mar 2012 21:21:49 +0100 Subject: MongoDB collection of articles is indexed with 'article_date'. --- mongodb.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mongodb.py') diff --git a/mongodb.py b/mongodb.py index a37b80c0..d00b453e 100644 --- a/mongodb.py +++ b/mongodb.py @@ -37,7 +37,7 @@ class Articles(object): """ collection = self.db[str(feed_id)] - collection.create_index([("article_link", pymongo.ASCENDING), ("article_date", pymongo.DESCENDING)], \ + collection.create_index([("article_date", pymongo.DESCENDING)], \ {"unique":False, "sparse":False}) for article in articles: @@ -105,8 +105,7 @@ class Articles(object): cursor = collection.find({"type":1}) else: cursor = collection.find({"type":1, condition[0]:condition[1]}) - #return cursor.sort([("article_date", pymongo.DESCENDING)]) - return cursor + return cursor.sort([("article_date", pymongo.DESCENDING)]) def print_articles_from_collection(self, collection_id): """ -- cgit