Skip to content

Commit

Permalink
MB-12251: Use the common function to parse the query parameters
Browse files Browse the repository at this point in the history
Instead of extracting the stale and debug parameter manually, use the
existing parse function to get the parameters. This makes things less
fragile and error prone.

Change-Id: I4949447dd37305531bc41bde78d0e0424e5b4d00
Reviewed-on: http://review.couchbase.org/42761
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
  • Loading branch information
vmx committed Nov 6, 2014
1 parent 37a81c7 commit ce037b9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions gc-couchbase/src/spatial_merger.erl
Expand Up @@ -430,10 +430,9 @@ simple_set_view_query(Params, DDoc, Req) ->
category = Category
} = SetViewSpec,

Stale = list_to_existing_atom(string:to_lower(
couch_httpd:qs_value(Req, "stale", "update_after"))),
Debug = couch_set_view_http:parse_bool_param(
couch_httpd:qs_value(Req, "debug", "false")),
QueryArgs = spatial_http:parse_qs(Req),
Debug = QueryArgs#spatial_query_args.debug,
% XXX vmx 2014-10-31: support the _type parameter properly
IndexType = list_to_existing_atom(
couch_httpd:qs_value(Req, "_type", "main")),
Partitions = case IndexType of
Expand All @@ -443,7 +442,7 @@ simple_set_view_query(Params, DDoc, Req) ->
[]
end,
GroupReq = #set_view_group_req{
stale = Stale,
stale = QueryArgs#spatial_query_args.stale,
update_stats = true,
wanted_partitions = Partitions,
debug = Debug,
Expand Down Expand Up @@ -472,12 +471,8 @@ simple_set_view_query(Params, DDoc, Req) ->
throw({error, set_view_outdated})
end,

% This code path is never triggered for _all_docs, hence we don't need
% to handle the special case to do raw collation for the query parameters
QueryArgs = spatial_http:parse_qs(Req),
QueryArgs2 = QueryArgs#spatial_query_args{
view_name = ViewName,
stale = Stale
view_name = ViewName
},

case couch_view_merger:debug_info(Debug, Group, GroupReq) of
Expand Down

0 comments on commit ce037b9

Please sign in to comment.