iilyak commented on a change in pull request #1744: Fix total_rows value for 
queries on `_design_docs` handler
URL: https://github.com/apache/couchdb/pull/1744#discussion_r234791695
 
 

 ##########
 File path: src/fabric/src/fabric_view_all_docs.erl
 ##########
 @@ -85,10 +85,13 @@ go(DbName, Options, QueryArgs, Callback, Acc0) ->
     Resp = case couch_util:get_value(namespace, Extra, <<"_all_docs">>) of
         <<"_local">> ->
             {ok, null};
-        _ ->
+        NS ->
 
 Review comment:
   I don't have strong opinion on this. The thing I don't really like is the 
fact that we have multiple places where we check for different values for 
namespace. Instead of a plane `case` with clauses for every possible value we 
have a `NS` clause and then have a second conditional there.  Would it be an 
option to extract this into a fun and call it like so:
   ```
    Resp = case couch_util:get_value(namespace, Extra, <<"_all_docs">>) of
           <<"_all_docs">> ->
               get_doc_counts(DbName, fun fabric:get_doc_count/1);
           <<"_design">> ->
               get_doc_counts(DbName, fun fabric:get_design_doc_count/1);
          <<"_local">> ->
               {ok, null};
   end
   ``` 
   
   It is a pity we don't have helper function for it. Since we have this 
pattern everywhere. Essentially `get_doc_counts` is `spawn_and_wait`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to