# HG changeset patch # User Dirk Olmes # Date 1293593278 -3600 # Node ID e59d722439b527b952974c61e11598183fe90f26 # Parent 3be4840789910a44abfc9d573fd23964d099fc84 filter out read entries first before sorting diff -r 3be484078991 -r e59d722439b5 Feed.py --- a/Feed.py Tue Dec 28 03:57:13 2010 +0100 +++ b/Feed.py Wed Dec 29 04:27:58 2010 +0100 @@ -6,7 +6,7 @@ @staticmethod def all(session): return session.query(Feed).order_by(Feed.title).all() - + def __init__(self, title, rss_url): self.title = title self.rss_url = rss_url @@ -21,17 +21,18 @@ def userPresentableString(self): return self.title - + def entriesSortedByUpdateDate(self, hideReadEntries=False): - sortedEntries = list(self.entries) + if hideReadEntries: + sortedEntries = self._unreadEntries() + else: + sortedEntries = list(self.entries) sortedEntries.sort(FeedEntry.compareByUpdateDate) - if hideReadEntries: - return self._filterReadEntries(sortedEntries) return sortedEntries - def _filterReadEntries(self, entries): + def _unreadEntries(self): retValue = [] - for entry in entries: + for entry in self.entries: if not entry.read: retValue.append(entry) return retValue