Github user wohali commented on a diff in the pull request:

    https://github.com/apache/couchdb-fabric/pull/1#discussion_r11654330
  
    --- Diff: src/fabric.erl ---
    @@ -278,15 +278,31 @@ query_view(DbName, DesignName, ViewName, QueryArgs) ->
     -spec query_view(dbname(), #doc{} | binary(), iodata(), callback(), any(),
             #mrargs{}) ->
         any().
    -query_view(DbName, Design, ViewName, Callback, Acc0, QueryArgs) ->
    +query_view(DbName, GroupId, ViewName, Callback, Acc0, QueryArgs)
    +        when is_binary(GroupId) ->
    +    {ok, DDoc} = ddoc_cache:open(DbName, <<"_design/", GroupId/binary>>),
    +    query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs);
    +query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
         Db = dbname(DbName), View = name(ViewName),
    -    case is_reduce_view(Db, Design, View, QueryArgs) of
    -    true ->
    -        Mod = fabric_view_reduce;
    -    false ->
    -        Mod = fabric_view_map
    -    end,
    -    Mod:go(Db, Design, View, QueryArgs, Callback, Acc0).
    +    {ok, #mrst{views=Views, language=Lang}} =
    +        couch_mrview_util:ddoc_to_mrst(Db, DDoc),
    +    QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views),
    +    QueryArgs2 = couch_mrview_util:validate_args(QueryArgs1),
    +    VInfo = couch_mrview_util:extract_view(Lang, QueryArgs2, View, Views),
    +    case is_reduce_view(QueryArgs2) of
    +        true ->
    +            fabric_view_reduce:go(
    +                Db,
    +                DDoc,
    +                View,
    +                QueryArgs2,
    +                Callback,
    +                Acc0,
    +                VInfo
    +            );
    +        false ->
    +            fabric_view_map:go(Db, DDoc, View, QueryArgs2, Callback, Acc0)
    --- End diff --
    
    Two things here:
    
    1. Indenting the `true` and `false` an additional indent level, which is 
good and I think rnewson is +1 on
    1. The breakout of all the arguments to fabric_view_reduce each to a single 
line, which looks decidedly sparse and isn't agreed to yet (and the original 
code had no arguments at all)
    
    Suggest a compromise?
    
    ```erlang
    case is_reduce_view(QueryArgs2) of
        true ->
            fabric_view_reduce:go(
                Db, DDoc, View, QueryArgs2, Callback, Acc0, VInfo
            );
        false ->
            fabric_view_map:go(Db, DDoc, View, QueryArgs2, Callback, Acc0)
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to