Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72EDD11AC0 for ; Sat, 23 Aug 2014 17:11:17 +0000 (UTC) Received: (qmail 38211 invoked by uid 500); 23 Aug 2014 17:11:17 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 38158 invoked by uid 500); 23 Aug 2014 17:11:17 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 38149 invoked by uid 99); 23 Aug 2014 17:11:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Aug 2014 17:11:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1CC8F955682; Sat, 23 Aug 2014 17:11:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: couch commit: updated refs/heads/windsor-merge to b676edd Date: Sat, 23 Aug 2014 17:11:17 +0000 (UTC) Repository: couchdb-couch Updated Branches: refs/heads/windsor-merge 2d593d9dd -> b676eddb3 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/b676eddb Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/b676eddb Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/b676eddb Branch: refs/heads/windsor-merge Commit: b676eddb39dd4e99038e6ce37f8ab43b5a79ad11 Parents: 2d593d9 Author: Robert Newson Authored: Sat Aug 23 14:30:22 2014 +0100 Committer: Robert Newson Committed: Sat Aug 23 18:11:02 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/b676eddb/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.