You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/08/23 19:10:37 UTC
[1/2] couch-stats commit: updated refs/heads/master to d7310e5
Repository: couchdb-couch-stats
Updated Branches:
refs/heads/master d06966579 -> d7310e546
Format nested functions properly
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/commit/1461beb1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/tree/1461beb1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/diff/1461beb1
Branch: refs/heads/master
Commit: 1461beb1acd912276d40d72113362b0a9905c4c0
Parents: d069665
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sat Aug 23 12:09:46 2014 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Sat Aug 23 12:10:23 2014 -0500
----------------------------------------------------------------------
src/couch_stats_httpd.erl | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/blob/1461beb1/src/couch_stats_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats_httpd.erl b/src/couch_stats_httpd.erl
index ad42930..b7abe63 100644
--- a/src/couch_stats_httpd.erl
+++ b/src/couch_stats_httpd.erl
@@ -36,16 +36,16 @@ transform_stats([{Key, Props} | Rest], Acc) ->
transform_stat(counter, Props) ->
Props;
transform_stat(histogram, Props) ->
- lists:map(
- fun({value, Value}) ->
- {value, lists:map(
- fun({Key, List}) when Key == percentile; Key == histogram ->
- {Key, [tuple_to_list(Item) || Item <- List]};
- (Else) ->
- Else
- end, Value)};
- (Else) ->
- Else
+ lists:map(fun
+ ({value, Value}) ->
+ {value, lists:map(fun
+ ({Key, List}) when Key == percentile; Key == histogram ->
+ {Key, [tuple_to_list(Item) || Item <- List]};
+ (Else) ->
+ Else
+ end, Value)};
+ (Else) ->
+ Else
end, Props).
[2/2] couch-stats commit: updated refs/heads/master to d7310e5
Posted by da...@apache.org.
Add sub-stat access at the HTTP layer
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/commit/d7310e54
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/tree/d7310e54
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/diff/d7310e54
Branch: refs/heads/master
Commit: d7310e546baf1685b5b2cd3007136f6d99b573dd
Parents: 1461beb
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sat Aug 23 12:10:11 2014 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Sat Aug 23 12:10:33 2014 -0500
----------------------------------------------------------------------
src/couch_stats_httpd.erl | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/blob/d7310e54/src/couch_stats_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats_httpd.erl b/src/couch_stats_httpd.erl
index b7abe63..fa817f6 100644
--- a/src/couch_stats_httpd.erl
+++ b/src/couch_stats_httpd.erl
@@ -15,12 +15,13 @@
-export([handle_stats_req/1]).
-handle_stats_req(#httpd{method='GET', path_parts=[_]}=Req) ->
+handle_stats_req(#httpd{method='GET', path_parts=[_ | Path]}=Req) ->
Stats0 = couch_stats:fetch(),
Stats = transform_stats(Stats0),
Nested = nest(Stats),
- EJSON = to_ejson(Nested),
- couch_httpd:send_json(Req, EJSON).
+ EJSON0 = to_ejson(Nested),
+ EJSON1 = extract_path(Path, EJSON0),
+ couch_httpd:send_json(Req, EJSON1).
transform_stats(Stats) ->
@@ -75,7 +76,22 @@ to_ejson(NotAProplist) ->
NotAProplist.
+extract_path([], EJSON) ->
+ EJSON;
+extract_path([Key | Rest], {Props}) ->
+ case proplists:lookup(Key, Props) of
+ {Key, SubEJSON} ->
+ extract_path(Rest, SubEJSON);
+ none ->
+ null
+ end;
+extract_path([_ | _], _NotAnObject) ->
+ null.
+
+
maybe_format_key(Key) when is_list(Key) ->
list_to_binary(Key);
-maybe_format_key(Key) ->
+maybe_format_key(Key) when is_atom(Key) ->
+ list_to_binary(atom_to_list(Key));
+maybe_format_key(Key) when is_binary(Key) ->
Key.