C0 code coverage information

Generated on 2009-08-09 21:22:55 with etap 0.3.4.

Name Total lines Lines of code Total coverage Code coverage
couch_httpd_stats_handlers ?? ?? ??
0% 
....1 % Licensed under the Apache License, Version 2.0 (the "License"); you may not
....2 % use this file except in compliance with the License. You may obtain a copy of
....3 % the License at
....4 %
....5 %   http://www.apache.org/licenses/LICENSE-2.0
....6 %
....7 % Unless required by applicable law or agreed to in writing, software
....8 % distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
....9 % WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
...10 % License for the specific language governing permissions and limitations under
...11 % the License.
...12 
...13 -module(couch_httpd_stats_handlers).
...14 -include("couch_db.hrl").
...15 -include("couch_stats.hrl").
...16 
...17 -export([handle_stats_req/1]).
...18 -import(couch_httpd,
...19     [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2,
...20     start_json_response/2,send_chunk/2,end_json_response/1,
...21     start_chunked_response/3, send_error/4]).
...22 
...23 -define(b2a(V), list_to_atom(binary_to_list(V))).
...24 
...25 -record(stats_query_args, {
...26     range='0',
...27     flush=false
...28 }).
...29 
...30 handle_stats_req(#httpd{method='GET', path_parts=[_]}=Req) ->
...31     send_json(Req, couch_stats_aggregator:all());
...32 
...33 handle_stats_req(#httpd{method='GET', path_parts=[_Stats, Module, Key]}=Req) ->
...34     #stats_query_args{
...35         range=Range,
...36         flush=Flush
...37     } = parse_stats_query(Req),
...38 
...39     case Flush of
...40         true ->
...41             couch_stats_aggregator:time_passed();
...42         _ -> ok
...43     end,
...44 
...45     Stats = couch_stats_aggregator:get_json({?b2a(Module), ?b2a(Key)}, Range),
...46     Response = {[{Module, {[{Key, Stats}]}}]},
...47     send_json(Req, Response);
...48 
...49 handle_stats_req(Req) ->
...50     send_method_not_allowed(Req, "GET").
...51 
...52 parse_stats_query(Req) ->
...53     lists:foldl(fun({Key,Value}, Args) ->
...54         case {Key, Value} of
...55         {"range", Range} ->
...56             Args#stats_query_args{range=list_to_atom(Range)};
...57         {"flush", "true"} ->
...58             Args#stats_query_args{flush=true};
...59         _Else -> % unknown key value pair, ignore.
...60             Args
...61         end
...62     end, #stats_query_args{}, couch_httpd:qs(Req)).

Generated using etap 0.3.4.