couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [06/22] couch commit: updated refs/heads/2491-refactor-couch-httpd-auth to 3e8286d
Date Thu, 04 Dec 2014 20:09:37 GMT
Make include_docs=true work for view changes


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

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

----------------------------------------------------------------------
 src/couch_changes.erl | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/20cd47e7/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index 8ff109b..29920da 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -643,9 +643,9 @@ changes_enumerator(Value0, Acc) ->
 
 changes_row(Results, DocInfo, #changes_acc{filter={fast_view,_,_,_}}=Acc) ->
     format_doc_info_change(Results, DocInfo, Acc);
-changes_row(Results, KV, #changes_acc{view=#mrview{}}) ->
-    {{Seq, Key}, {Id, Value, _Rev}} = KV,
-    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key},
{<<"value">>, Value}, {<<"changes">>, Results}]};
+changes_row(Results, KV, #changes_acc{view=#mrview{}}=Acc) ->
+    {{Seq, Key}, {Id, Value, Rev}} = KV,
+    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key},
{<<"value">>, Value}, {<<"changes">>, Results}] ++ maybe_get_changes_doc({Id,
Rev}, Acc)};
 changes_row(Results, #doc_info{}=DocInfo, Acc) ->
     format_doc_info_change(Results, DocInfo, Acc).
 
@@ -653,29 +653,35 @@ format_doc_info_change(Results, #doc_info{}=DocInfo, Acc) ->
     #doc_info{
         id = Id, high_seq = Seq, revs = [#rev_info{deleted = Del} | _]
     } = DocInfo,
+    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>,
Results}] ++
+        deleted_item(Del) ++ maybe_get_changes_doc(DocInfo, Acc)}.
+
+maybe_get_changes_doc(Value, #changes_acc{include_docs=true}=Acc) ->
     #changes_acc{
         db = Db,
         include_docs = IncDoc,
         doc_options = DocOpts,
         conflicts = Conflicts
     } = Acc,
-    {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>,
Results}] ++
-        deleted_item(Del) ++ case IncDoc of
-            true ->
-                Opts = case Conflicts of
-                    true -> [deleted, conflicts];
-                    false -> [deleted]
-                end,
-                Doc = couch_index_util:load_doc(Db, DocInfo, Opts),
-                case Doc of
-                    null ->
-                        [{doc, null}];
-                    _ ->
-                        [{doc, couch_doc:to_json_obj(Doc, DocOpts)}]
-                end;
-            false ->
-                []
-        end}.
+    case IncDoc of
+        true ->
+            Opts = case Conflicts of
+                true -> [deleted, conflicts];
+                false -> [deleted]
+            end,
+            Doc = couch_index_util:load_doc(Db, Value, Opts),
+            case Doc of
+                null ->
+                    [{doc, null}];
+                _ ->
+                    [{doc, couch_doc:to_json_obj(Doc, DocOpts)}]
+            end;
+        false ->
+            []
+    end;
+maybe_get_changes_doc(_Value, _Acc) ->
+    [].
+
 
 deleted_item(true) -> [{<<"deleted">>, true}];
 deleted_item(_) -> [].


Mime
View raw message