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


##########
src/couch_mrview/src/couch_mrview.erl:
##########
@@ -532,35 +532,61 @@ map_fold({{Key, Id}, Val}, _Offset, Acc) ->
         last_go = Go
     }};
 map_fold(#doc{id = <<"_local/", _/binary>>} = Doc, _Offset, #mracc{} = Acc) ->
-    #mracc{
-        limit = Limit,
-        callback = Callback,
-        user_acc = UAcc0,
-        args = Args
-    } = Acc,
-    #doc{
-        id = DocId,
-        revs = {Pos, [RevId | _]}
-    } = Doc,
-    Rev = {Pos, RevId},
-    Row =
-        [
-            {id, DocId},
-            {key, DocId},
-            {value, {[{rev, couch_doc:rev_to_str(Rev)}]}}
-        ] ++
-            if
-                not Args#mrargs.include_docs -> [];
-                true -> [{doc, couch_doc:to_json_obj(Doc, 
Args#mrargs.doc_options)}]
-            end,
-    {Go, UAcc1} = Callback({row, Row}, UAcc0),
-    {Go, Acc#mracc{
-        limit = Limit - 1,
-        reduce_fun = undefined,
-        doc_info = undefined,
-        user_acc = UAcc1,
-        last_go = Go
-    }}.
+    IncludeSys = couch_util:get_value(include_system, 
Acc#mracc.args#mrargs.extra),
+
+    case should_skip_local_document(IncludeSys, Doc) of
+        true ->
+            {ok, Acc};
+        _ ->
+            #mracc{
+                limit = Limit,
+                callback = Callback,
+                user_acc = UAcc0,
+                args = Args
+            } = Acc,
+            #doc{
+                id = DocId,
+                revs = {Pos, [RevId | _]}
+            } = Doc,
+            Rev = {Pos, RevId},
+            Row =
+                [
+                    {id, DocId},
+                    {key, DocId},
+                    {value, {[{rev, couch_doc:rev_to_str(Rev)}]}}
+                ] ++
+                    if
+                        not Args#mrargs.include_docs -> [];
+                        true -> [{doc, couch_doc:to_json_obj(Doc, 
Args#mrargs.doc_options)}]
+                    end,
+            {Go, UAcc1} = Callback({row, Row}, UAcc0),
+            {Go, Acc#mracc{
+                limit = Limit - 1,
+                reduce_fun = undefined,
+                doc_info = undefined,
+                user_acc = UAcc1,
+                last_go = Go
+            }}
+    end.
+
+should_skip_local_document(_IncludeSys = false, #doc{

Review Comment:
   It's plausible a user would have a "_local/purge-1" document of some sort. 
`"shard-sync-..."` probably a lot less likely. That was the reason for 
suggesting the extra fields check.



-- 
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