couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [09/22] couch commit: updated refs/heads/2491-refactor-couch-httpd-auth to 3e8286d
Date Thu, 04 Dec 2014 20:09:40 GMT
Open view in changes start function rather than outside


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8d5c9009
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8d5c9009
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8d5c9009

Branch: refs/heads/2491-refactor-couch-httpd-auth
Commit: 8d5c90094214ad186641fe25f1c70d621adda378
Parents: 434b541
Author: Benjamin Bastian <benjamin.bastian@gmail.com>
Authored: Tue Aug 26 15:34:21 2014 +0700
Committer: Benjamin Bastian <benjamin.bastian@gmail.com>
Committed: Fri Oct 31 12:43:53 2014 -0700

----------------------------------------------------------------------
 src/couch_changes.erl | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8d5c9009/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index 50f9d50..8ff109b 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -73,7 +73,7 @@ handle_changes(Args1, Req, Db0, Type) ->
         _ ->
             false
     end,
-    {StartListenerFun, DDocName, ViewName, View} = if UseViewChanges ->
+    {StartListenerFun, DDocName, ViewName} = if UseViewChanges ->
         {DDocName0, ViewName0} = case {Type, Filter} of
             {{view, DDocName1, ViewName1}, _} ->
                 {DDocName1, ViewName1};
@@ -93,14 +93,14 @@ handle_changes(Args1, Req, Db0, Type) ->
                  ?MODULE, handle_view_event, {self(), DDocName0}, [{dbname, Db0#db.name}]
             )
         end,
-        {SNFun, DDocName0, ViewName0, View0};
-    true ->
+        {SNFun, DDocName0, ViewName0};
+     true ->
         SNFun = fun() ->
             couch_event:link_listener(
                  ?MODULE, handle_db_event, self(), [{dbname, Db0#db.name}]
             )
         end,
-        {SNFun, undefined, undefined, undefined}
+        {SNFun, undefined, undefined}
     end,
     Start = fun() ->
         {ok, Db} = couch_db:reopen(Db0),
@@ -110,7 +110,14 @@ handle_changes(Args1, Req, Db0, Type) ->
         fwd ->
             Since
         end,
-        {Db, StartSeq}
+        View2 = if UseViewChanges ->
+            {ok, {_, View1, _}, _, _} = couch_mrview_util:get_view(
+                    Db0#db.name, DDocName, ViewName, #mrargs{}),
+            View1;
+        true ->
+            undefined
+        end,
+        {Db, View2, StartSeq}
     end,
     % begin timer to deal with heartbeat when filter function fails
     case Args#changes_args.heartbeat of
@@ -126,7 +133,7 @@ handle_changes(Args1, Req, Db0, Type) ->
             {Callback, UserAcc} = get_callback_acc(CallbackAcc),
             {ok, Listener} = StartListenerFun(),
 
-            {Db, StartSeq} = Start(),
+            {Db, View, StartSeq} = Start(),
             UserAcc2 = start_sending_changes(Callback, UserAcc, Feed),
             {Timeout, TimeoutFun} = get_changes_timeout(Args, Callback),
             Acc0 = build_acc(Args, Callback, UserAcc2, Db, StartSeq,
@@ -147,7 +154,7 @@ handle_changes(Args1, Req, Db0, Type) ->
             {Callback, UserAcc} = get_callback_acc(CallbackAcc),
             UserAcc2 = start_sending_changes(Callback, UserAcc, Feed),
             {Timeout, TimeoutFun} = get_changes_timeout(Args, Callback),
-            {Db, StartSeq} = Start(),
+            {Db, View, StartSeq} = Start(),
             Acc0 = build_acc(Args#changes_args{feed="normal"}, Callback,
                              UserAcc2, Db, StartSeq, <<>>, Timeout, TimeoutFun,
                              DDocName, ViewName, View),


Mime
View raw message