davisp commented on a change in pull request #1804: Make view query limits 
configurable
URL: https://github.com/apache/couchdb/pull/1804#discussion_r240324074
 
 

 ##########
 File path: src/couch_mrview/src/couch_mrview_util.erl
 ##########
 @@ -525,6 +527,39 @@ validate_args(#mrst{} = State, Args0) ->
     end.
 
 
+apply_limit(ViewPartitioned, Args) ->
+    MaxLimitType = case ViewPartitioned of
+        true -> "partition_";
+        false -> ""
+    end,
+    
+    MaxLimit = case config:get("query_server_config",
+        MaxLimitType ++ "query_limit", "infinity") of
+        "infinity" -> infinity;
+        N -> list_to_integer(N)
+    end,
+
+    % set the highest limit possible if a user has not 
+    % specified a limit
+    Args1 = case Args#mrargs.limit =:= ?MAX_VIEW_LIMIT
+        andalso MaxLimit =/= infinity of
+        false ->
+            Args;
+        true ->
+            Args#mrargs{
+                limit = MaxLimit
+            }
+    end,
+
+    case Args1#mrargs.limit > MaxLimit of
 
 Review comment:
   The if statement would make this a bit cleaner I think:
   
   ```erlang
   if Args1#mrargs.limit < MaxLimit -> ok; true ->
       Fmt = "...".
       mrverror(...)
   end,
   
   Args1.
   ```

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