couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davisp <...@git.apache.org>
Subject [GitHub] couchdb-couch-mrview pull request: Add view changes functionality
Date Wed, 22 Oct 2014 18:32:14 GMT
Github user davisp commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-mrview/pull/2#discussion_r19234375
  
    --- Diff: src/couch_mrview_http.erl ---
    @@ -46,7 +48,46 @@ handle_all_docs_req(#httpd{method='POST'}=Req, Db) ->
     handle_all_docs_req(Req, _Db) ->
         couch_httpd:send_method_not_allowed(Req, "GET,POST,HEAD").
     
    +handle_reindex_req(#httpd{method='POST',
    +                          path_parts=[_, _, DName,<<"_reindex">>]}=Req,
    +                   Db, DDoc) ->
    +    ok = couch_db:check_is_admin(Db),
    +    couch_mrview:trigger_update(Db, <<"_design/", DName/binary>>),
    +    couch_httpd:send_json(Req, 201, {[{<<"ok">>, true}]});
    +handle_reindex_req(Req, _Db, _DDoc) ->
    +    couch_httpd:send_method_not_allowed(Req, "POST").
    +
    +
    +handle_view_changes_req(#httpd{path_parts=[_,<<"_design">>,DDocName,<<"_view_changes">>,ViewName]}=Req,
Db, DDoc) ->
    +    {DDocBody} = DDoc#doc.body,
    +    case lists:keyfind(<<"options">>, 1, DDocBody) of
    +        {<<"options">>, {Options}} when is_list(Options) ->
    +            case lists:keyfind(<<"seq_indexed">>, 1, Options) of
    +                {<<"seq_indexed">>, true} ->
    +                    ok;
    +                _ ->
    +                    throw({bad_request, "view changes not enabled"})
    +            end;
    +        _ ->
    +            throw({bad_request, "view changes not enabled"})
    +    end,
    +
    +    ChangesArgs = couch_httpd_db:parse_changes_query(Req, Db),
    +    ChangesFun = couch_mrview_changes:handle_view_changes(ChangesArgs, Req, Db, <<"_design/",
DDocName/binary>>, ViewName),
    +    couch_httpd_db:handle_changes_req(Req, Db, ChangesArgs, ChangesFun).
     
    +
    +handle_view_req(#httpd{method='GET',
    +                      path_parts=[_, _, DDocName, _, VName, <<"_info">>]}=Req,
    +                Db, _DDoc) ->
    --- End diff --
    
    Another odd API addition in the changes code?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message