You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by bb...@apache.org on 2014/10/31 20:53:30 UTC
[07/11] couch commit: updated refs/heads/master to 6125862
Add rev to view changes respose. See couch_mrview for corresponding 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/434b5414
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/434b5414
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/434b5414
Branch: refs/heads/master
Commit: 434b5414ed975747e8144f9c5542cefa3f83fe3c
Parents: 20e585d
Author: Benjamin Bastian <be...@gmail.com>
Authored: Mon Aug 25 16:50:05 2014 +0700
Committer: Benjamin Bastian <be...@gmail.com>
Committed: Fri Oct 31 12:43:53 2014 -0700
----------------------------------------------------------------------
src/couch_changes.erl | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/434b5414/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index 259f83c..50f9d50 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -265,7 +265,7 @@ filter(Db, DocInfo, {custom, Style, Req0, DDoc, FName}) ->
{ok, Passes} = couch_query_servers:filter_docs(Req, Db, DDoc, FName, Docs),
filter_revs(Passes, Docs).
-fast_view_filter(Db, {{Seq, _}, {ID, _}}, {fast_view, Style, _, _}) ->
+fast_view_filter(Db, {{Seq, _}, {ID, _, _}}, {fast_view, Style, _, _}) ->
case couch_db:get_doc_info(Db, ID) of
{ok, #doc_info{high_seq=Seq}=DocInfo} ->
Docs = open_revs(Db, DocInfo, Style),
@@ -284,15 +284,15 @@ fast_view_filter(Db, {{Seq, _}, {ID, _}}, {fast_view, Style, _, _}) ->
% I left the Seq > HighSeq guard in so if (for some godforsaken
% reason) the seq in the view is more current than the database,
% we'll throw an error.
- {ok, []};
+ {undefined, []};
{error, not_found} ->
- {ok, []}
+ {undefined, []}
end.
-view_filter(_Db, _KV, {default, _Style}) ->
- [ok]. % TODO: make a real thing
+view_filter(Db, KV, {default, Style}) ->
+ apply_view_style(Db, KV, Style).
get_view_qs({json_req, {Props}}) ->
@@ -353,6 +353,16 @@ apply_style(#doc_info{revs=Revs}, main_only) ->
apply_style(#doc_info{revs=Revs}, all_docs) ->
[{[{<<"rev">>, couch_doc:rev_to_str(R)}]} || #rev_info{rev=R} <- Revs].
+apply_view_style(_Db, {{_Seq, _Key}, {_ID, _Value, Rev}}, main_only) ->
+ [{[{<<"rev">>, couch_doc:rev_to_str(Rev)}]}];
+apply_view_style(Db, {{_Seq, _Key}, {ID, _Value, _Rev}}, all_docs) ->
+ case couch_db:get_doc_info(Db, ID) of
+ {ok, DocInfo} ->
+ apply_style(DocInfo, all_docs);
+ {error, not_found} ->
+ []
+ end.
+
open_revs(Db, DocInfo, Style) ->
DocInfos = case Style of
@@ -627,7 +637,7 @@ 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}} = KV,
+ {{Seq, Key}, {Id, Value, _Rev}} = KV,
{[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key}, {<<"value">>, Value}, {<<"changes">>, Results}]};
changes_row(Results, #doc_info{}=DocInfo, Acc) ->
format_doc_info_change(Results, DocInfo, Acc).