You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/26 11:46:21 UTC

[26/26] couch commit: updated refs/heads/windsor-merge to 14dc5e9

Move couch stats handler to couch_stats


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/14dc5e93
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/14dc5e93
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/14dc5e93

Branch: refs/heads/windsor-merge
Commit: 14dc5e93d79b438a794f594f5555766c44a9b231
Parents: 0f35575
Author: Robert Newson <rn...@apache.org>
Authored: Sat Aug 23 14:30:22 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Aug 26 10:44:13 2014 +0100

----------------------------------------------------------------------
 src/couch_httpd_stats_handlers.erl | 53 ---------------------------------
 1 file changed, 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/14dc5e93/src/couch_httpd_stats_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_stats_handlers.erl b/src/couch_httpd_stats_handlers.erl
deleted file mode 100644
index 88376ab..0000000
--- a/src/couch_httpd_stats_handlers.erl
+++ /dev/null
@@ -1,53 +0,0 @@
-% Licensed under the Apache License, Version 2.0 (the "License"); you may not
-% use this file except in compliance with the License. You may obtain a copy of
-% the License at
-%
-%   http://www.apache.org/licenses/LICENSE-2.0
-%
-% Unless required by applicable law or agreed to in writing, software
-% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-% License for the specific language governing permissions and limitations under
-% the License.
-
--module(couch_httpd_stats_handlers).
--include("couch_db.hrl").
-
--export([handle_stats_req/1]).
-
-handle_stats_req(#httpd{method='GET', path_parts=[_]}=Req) ->
-    Stats = couch_stats:fetch(),
-    Nested = nest(Stats),
-    EJSON = to_ejson(Nested),
-    couch_httpd:send_json(Req, EJSON).
-
-nest(Proplist) ->
-    nest(Proplist, []).
-
-nest([], Acc) ->
-    Acc;
-nest([{[Key|Keys], Value}|Rest], Acc) ->
-    Acc1 = case proplists:lookup(Key, Acc) of
-        {Key, Old} ->
-            [{Key, nest([{Keys, Value}], Old)}|proplists:delete(Key, Acc)];
-        none ->
-            Term = lists:foldr(fun(K, A) -> [{K, A}] end, Value, Keys),
-            [{Key, Term}|Acc]
-    end,
-    nest(Rest, Acc1).
-
-to_ejson([{_, _}|_]=Proplist) ->
-    EJSONProps = lists:map(
-       fun({Key, Value}) -> {maybe_format_key(Key), to_ejson(Value)} end,
-       Proplist
-    ),
-    {EJSONProps};
-to_ejson(NotAProplist) ->
-    NotAProplist.
-
-maybe_format_key(Key) when is_integer(Key) ->
-    maybe_format_key(integer_to_list(Key));
-maybe_format_key(Key) when is_list(Key) ->
-    list_to_binary(Key);
-maybe_format_key(Key) ->
-    Key.