# HG changeset patch # User dirk # Date 1315638314 -7200 # Node ID 1ab48428e2f9ed5f03a51fcd8c4697d2dc33246b # Parent a4832a180c695f15519416bb1512988c68f7b757 sort the feed entries diff -r a4832a180c69 -r 1ab48428e2f9 backend/couchdb/CouchDbBackend.py --- a/backend/couchdb/CouchDbBackend.py Sat Sep 10 04:43:40 2011 +0200 +++ b/backend/couchdb/CouchDbBackend.py Sat Sep 10 09:05:14 2011 +0200 @@ -55,7 +55,10 @@ # TODO how to hide read entries if requested? viewResults = FeedEntry.view(self.database, CouchDb.feedEntriesByFeed(), key=self.selectedFeed.id) - return list(viewResults) + viewResults = list(viewResults) + # TODO update date is a string ... convert to a ListDateTimeField for better sort support + viewResults.sort(FeedEntry.compareByUpdateDate, reverse=True) + return viewResults def markSelectedFeedAsRead(self): for feedEntry in self.entriesForSelectedFeed(): diff -r a4832a180c69 -r 1ab48428e2f9 backend/couchdb/FeedEntry.py --- a/backend/couchdb/FeedEntry.py Sat Sep 10 04:43:40 2011 +0200 +++ b/backend/couchdb/FeedEntry.py Sat Sep 10 09:05:14 2011 +0200 @@ -26,9 +26,12 @@ def getReadFeedEntriesOlderThan(timestamp, database): end = [timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second] -# end = str(end).replace(" ", "") return FeedEntry.view(database, CouchDb.readFeedEntriesByCreateDate(), endkey=end) + @staticmethod + def compareByUpdateDate(first, second): + return cmp(first, second) + def markRead(self, database): self.read = True self.store(database)