diff Feed.py @ 99:e59d722439b5

filter out read entries first before sorting
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 29 Dec 2010 04:27:58 +0100
parents d292ab61ed6f
children
line wrap: on
line diff
--- 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