changeset 175:57e324fa4350

implement getting a list of feeds that have unread entries
author dirk
date Fri, 09 Sep 2011 18:17:57 +0200
parents d0ced79b5030
children 7001070d0bd5
files backend/couchdb/CouchApp/feedworm/views/feeds_with_unread_entries/map.js backend/couchdb/CouchApp/feedworm/views/feeds_with_unread_entries/reduce.js backend/couchdb/CouchDb.py backend/couchdb/CouchDbBackend.py
diffstat 4 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/couchdb/CouchApp/feedworm/views/feeds_with_unread_entries/map.js	Fri Sep 09 18:17:57 2011 +0200
@@ -0,0 +1,7 @@
+function(doc)
+{
+    if (doc.doctype == "feedEntry")
+    {
+        emit(doc.feed, null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/couchdb/CouchApp/feedworm/views/feeds_with_unread_entries/reduce.js	Fri Sep 09 18:17:57 2011 +0200
@@ -0,0 +1,4 @@
+function(keys, values, rereduce)
+{
+  return true;
+}
--- a/backend/couchdb/CouchDb.py	Fri Sep 09 17:21:34 2011 +0200
+++ b/backend/couchdb/CouchDb.py	Fri Sep 09 18:17:57 2011 +0200
@@ -33,4 +33,5 @@
 def readFeedEntriesByCreateDate():
     return database + "/read_feedEntries_by_create_date"
 
-
+def feedsWithUnreadEntries():
+    return database + "/feeds_with_unread_entries"
--- a/backend/couchdb/CouchDbBackend.py	Fri Sep 09 17:21:34 2011 +0200
+++ b/backend/couchdb/CouchDbBackend.py	Fri Sep 09 18:17:57 2011 +0200
@@ -38,7 +38,11 @@
         return self.feeds
 
     def _getUnreadFeeds(self):
-        raise Exception("not yet implemented")
+        viewResults = self.database.view(CouchDb.feedsWithUnreadEntries(), group=True)
+        feeds = []
+        for row in viewResults:
+            feeds.append(Feed.load(self.database, row["key"]))
+        return feeds
 
     def _retrieveEntriesForSelectedFeed(self, hideReadEntries):
         # TODO how to hide read entries if requested?