diff options
author | Adam Kocoloski <adam@cloudant.com> | 2010-06-11 17:06:30 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2010-08-12 11:18:45 -0400 |
commit | 35bc59279c9d6de45e27ce87573eeeacfda9289e (patch) | |
tree | 3644f0cd18eeeb2a2a77c4151fa925388718eb46 /src/chttpd_view.erl | |
parent | f4d7191a3c0c37fe7b2ba290ba3e1afda0269863 (diff) |
support for sorted=false map views over HTTP. BugzID 10073
Diffstat (limited to 'src/chttpd_view.erl')
-rw-r--r-- | src/chttpd_view.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl index 9ca0c3a1..f49e232d 100644 --- a/src/chttpd_view.erl +++ b/src/chttpd_view.erl @@ -51,8 +51,11 @@ view_callback({total_and_offset, Total, Offset}, {nil, Resp}) -> Chunk = "{\"total_rows\":~p,\"offset\":~p,\"rows\":[\r\n", send_chunk(Resp, io_lib:format(Chunk, [Total, Offset])), {ok, {"", Resp}}; +view_callback({total_and_offset, _, _}, Acc) -> + % a sorted=false view where the message came in late. Ignore. + {ok, Acc}; view_callback({row, Row}, {nil, Resp}) -> - % first row of a reduce view + % first row of a reduce view, or a sorted=false view send_chunk(Resp, ["{\"rows\":[\r\n", ?JSON_ENCODE(Row)]), {ok, {",\r\n", Resp}}; view_callback({row, Row}, {Prepend, Resp}) -> @@ -342,6 +345,8 @@ parse_view_param("callback", _) -> []; % Verified in the JSON response functions parse_view_param("show_total_rows", Value) -> [{show_total_rows, parse_bool_param(Value)}]; +parse_view_param("sorted", Value) -> + [{sorted, parse_bool_param(Value)}]; parse_view_param(Key, Value) -> [{extra, {Key, Value}}]. @@ -427,6 +432,10 @@ validate_view_query(show_total_rows, false, Args) -> Args#view_query_args{show_total_rows=false}; validate_view_query(show_total_rows, _Value, Args) -> Args; +validate_view_query(sorted, false, Args) -> + Args#view_query_args{sorted=false}; +validate_view_query(sorted, _Value, Args) -> + Args; validate_view_query(extra, _Value, Args) -> Args. |