nickva commented on code in PR #5602: URL: https://github.com/apache/couchdb/pull/5602#discussion_r2220346513
########## src/couch_stats/src/csrt_httpd.erl: ########## @@ -0,0 +1,169 @@ +% 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(csrt_httpd). +-include_lib("couch/include/couch_db.hrl"). +-include_lib("csrt.hrl"). + +-export([handle_resource_status_req/1]). + +-import( + chttpd, + [ + send_json/2, send_json/3, + send_method_not_allowed/2 + ] +). + +-import( + csrt, + [ + query/1, + from/1, + group_by/1, + group_by/2, + sort_by/1, + sort_by/2, + count_by/1, + options/1, + unlimited/0, + with_limit/1, + + run/1 + ] +). Review Comment: That could make sense in general but I think it can still use some cleanup in this case. For instance I see `{Keys, csrt:query([from(MatcherName), count_by(Keys)])};` but then also ` {Keys, query([from(MatcherName), sort_by(Keys, CounterKey)])};` * `couch_util:value(...)` doesn't have the shortened imported format but seems just as verbose as csrt:from(...) * `with_limit/1` doesn't seem to be used but is imported There 17 lines of imports but only 3 lines of `query(...)` calls so it seems overkill in this module as at least? Sometimes to avoid imports if we're really repeating the same call too often we can make a few short local functions. Say, if we call `erlang:monotonic_time()` then could make local one-line function called `tnow() -> erlang:monotonic_time()` then we can call that 20 or 30 times and it looks a bit better. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org