summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-11-16 20:10:34 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-11-16 20:10:34 +0000
commit2bc2dc1ad85943214a21597723ab4b357fbe1766 (patch)
tree44127401e0e7948ca2598dd0019bf794e315cfcd /src/couchdb
parent7d5b19ed61f904905da4d0598754ef4405baba85 (diff)
Some code simplifications to the couch_changes module.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1035778 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_changes.erl31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index 9009ef1c..ec0beb57 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -78,14 +78,10 @@ get_callback_acc(Callback) when is_function(Callback, 2) ->
{fun(Ev, Data, _) -> Callback(Ev, Data) end, ok}.
%% @type Req -> #httpd{} | {json_req, JsonObj()}
+make_filter_fun([$_ | _] = FilterName, Style, Req, Db) ->
+ builtin_filter_fun(FilterName, Style, Req, Db);
make_filter_fun(FilterName, Style, Req, Db) ->
- FilterName1 = list_to_binary(FilterName),
- case FilterName1 of
- (<<"_", _/binary>>) ->
- builtin_filter_fun(FilterName1, Style, Req, Db);
- (_OSFun) ->
- os_filter_fun(FilterName, Style, Req, Db)
- end.
+ os_filter_fun(FilterName, Style, Req, Db).
os_filter_fun(FilterName, Style, Req, Db) ->
case [list_to_binary(couch_httpd:unquote(Part))
@@ -123,26 +119,17 @@ os_filter_fun(FilterName, Style, Req, Db) ->
"filter parameter must be of the form `designname/filtername`"})
end.
-builtin_filter_fun(<<"_doc_ids",_/binary>>, Style,
- #httpd{method='POST'}=Req, _Db) ->
+builtin_filter_fun("_doc_ids", Style, #httpd{method='POST'}=Req, _Db) ->
{Props} = couch_httpd:json_body_obj(Req),
DocIds = couch_util:get_value(<<"doc_ids">>, Props, nil),
filter_docids(DocIds, Style);
-builtin_filter_fun(<<"_doc_ids", _/binary>>, Style,
- #httpd{method='GET'}=Req, _Db) ->
- QS = couch_httpd:qs(Req),
- DocIds = case couch_util:get_value("doc_ids", QS, nil) of
- nil ->
- throw({bad_request, "`doc_ids` parameter is not set"});
- DocIds1 ->
- ?JSON_DECODE(DocIds1)
- end,
+builtin_filter_fun("_doc_ids", Style, #httpd{method='GET'}=Req, _Db) ->
+ DocIds = ?JSON_DECODE(couch_httpd:qs_value(Req, "doc_ids", "null")),
filter_docids(DocIds, Style);
-builtin_filter_fun(<<"_design", _/binary>>, Style, _Req, _Db) ->
+builtin_filter_fun("_design", Style, _Req, _Db) ->
filter_designdoc(Style);
builtin_filter_fun(_FilterName, _Style, _Req, _Db) ->
- throw({bad_request,
- "unknown builtin filter name"}).
+ throw({bad_request, "unknown builtin filter name"}).
filter_docids(DocIds, Style) when is_list(DocIds)->
fun(#doc_info{id=DocId, revs=Revs}) ->
@@ -153,7 +140,7 @@ filter_docids(DocIds, Style) when is_list(DocIds)->
end
end;
filter_docids(_, _) ->
- throw({bad_request, "`doc_ids` member must be defined as a list"}).
+ throw({bad_request, "`doc_ids` filter parameter is not a list."}).
filter_designdoc(Style) ->
fun(#doc_info{id=DocId, revs=Revs}) ->