nickva commented on code in PR #4862:
URL: https://github.com/apache/couchdb/pull/4862#discussion_r1422849935


##########
src/couch/src/couch_changes.erl:
##########
@@ -264,6 +264,26 @@ filter(Db, DocInfo, {custom, Style, Req0, DDoc, FName}) ->
     {ok, Passes} = couch_query_servers:filter_docs(Req, Db, DDoc, FName, Docs),
     filter_revs(Passes, Docs).
 
+filter(Db, DocInfo, {selector, Style, {Selector, _Fields}}, true) ->
+    Docs = open_revs(Db, DocInfo, Style),
+    Passes = [mango_selector:match(Selector, couch_doc:to_json_obj(Doc, [])) 
|| Doc <- Docs],
+    {Docs, filter_revs(Passes, Docs)};
+filter(Db, DocInfo, {view, Style, DDoc, VName}, true) ->
+    Docs = open_revs(Db, DocInfo, Style),
+    {ok, Passes} = couch_query_servers:filter_view(Db, DDoc, VName, Docs),
+    {Docs, filter_revs(Passes, Docs)};
+filter(Db, DocInfo, {custom, Style, Req0, DDoc, FName}, true) ->
+    Req =
+        case Req0 of
+            {json_req, _} -> Req0;
+            #httpd{} -> {json_req, chttpd_external:json_req_obj(Req0, Db)}
+        end,
+    Docs = open_revs(Db, DocInfo, Style),
+    {ok, Passes} = couch_query_servers:filter_docs(Req, Db, DDoc, FName, Docs),
+    {Docs, filter_revs(Passes, Docs)};
+filter(Db, DocInfo, Filter, _IncludeDocs) ->
+    {[], filter(Db, DocInfo, Filter)}.
+

Review Comment:
   For the 3 filter types we are essentially duplicating the code for filter/4 
and filter/3. The only difference seems to be that when we pass 
`IncludeDocs=true` we also return Docs otherwise we return `[]`. Could we 
combine the cases so all filter calls are filter/4?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to