You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/10/16 09:33:43 UTC

[GitHub] garrensmith commented on a change in pull request #1605: Feature/user partitioned databases

garrensmith commented on a change in pull request #1605: Feature/user partitioned databases
URL: https://github.com/apache/couchdb/pull/1605#discussion_r225465589
 
 

 ##########
 File path: src/chttpd/src/chttpd_view.erl
 ##########
 @@ -101,6 +112,56 @@ handle_temp_view_req(Req, _Db) ->
     chttpd:send_error(Req, 410, gone, Msg).
 
 
+handle_partition_view_req(#httpd{method='POST',
+        path_parts=[_, _, _, _, _, _, ViewName]} = Req, Db, DDoc, Partition) ->
+    chttpd:validate_ctype(Req, "application/json"),
+    Props = couch_httpd:json_body_obj(Req),
+    Keys = couch_mrview_util:get_view_keys(Props),
+    case Keys of
+        Keys when is_list(Keys) ->
+            couch_stats:increment_counter([couchdb, httpd, view_reads]),
+            Args0 = couch_mrview_http:parse_params(Req, Keys),
+            Args1 = couch_mrview_util:set_extra(Args0, partition, Partition),
+            Args2 = couch_mrview_util:set_extra(Args1, partitioned, true),
+            ok = check_partition_restrictions(Args2),
+            design_doc_view_int(Req, Db, DDoc, ViewName, Args2);
+        _ ->
+            throw({
+                bad_request,
+                "POST body must contain `keys` field"
+            })
+    end;
+
+handle_partition_view_req(#httpd{method='GET',
+        path_parts=[_, _, _, _, _, _, ViewName]} = Req, Db, DDoc, Partition) ->
+    Keys = chttpd:qs_json_value(Req, "keys", undefined),
+    Args = couch_mrview_http:parse_params(Req, Keys),
+    Args1 = couch_mrview_util:set_extra(Args, partition, Partition),
+    Args2 = couch_mrview_util:set_extra(Args1, partitioned, true),
+    ok = check_partition_restrictions(Args2),
+    design_doc_view_int(Req, Db, DDoc, ViewName, Args2);
+
+handle_partition_view_req(Req, _Db, _DDoc, _Pk) ->
+        chttpd:send_method_not_allowed(Req, "GET").
+
+
+check_partition_restrictions(#mrargs{} = Args) ->
+    Restrictions = [
+        {<<"include_docs">>, Args#mrargs.include_docs, true},
+        {<<"stable">>, Args#mrargs.stable, true},
+        {<<"conflicts">>, Args#mrargs.conflicts, true}
+    ],
+    lists:foreach(fun ({Param, Field, Value}) ->
 
 Review comment:
   I'm going to rename to `ArgValue` and `RestrictedValue`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services