Mercurial > hg > Feedworm
changeset 181:1ab48428e2f9
sort the feed entries
author | dirk |
---|---|
date | Sat, 10 Sep 2011 09:05:14 +0200 |
parents | a4832a180c69 |
children | 964661153b97 |
files | backend/couchdb/CouchDbBackend.py backend/couchdb/FeedEntry.py |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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():
--- 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)