jaydoane commented on a change in pull request #3969:
URL: https://github.com/apache/couchdb/pull/3969#discussion_r839974004
##########
File path: src/chttpd/src/chttpd_misc.erl
##########
@@ -144,32 +145,24 @@ all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} =
Acc) when
Acc#vacc.req#httpd.path_parts =:= [<<"_all_dbs">>]
->
Prepend = couch_mrview_http:prepend_val(Acc),
- case couch_util:get_value(id, Row) of
- <<"_design", _/binary>> ->
- {ok, Acc};
- DbName ->
- {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend,
?JSON_ENCODE(DbName)]),
- {ok, Acc#vacc{prepend = ",", resp = Resp1}}
- end;
+ DbName = couch_util:get_value(id, Row),
+ {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend,
?JSON_ENCODE(DbName)]),
+ {ok, Acc#vacc{prepend = ",", resp = Resp1}};
Review comment:
❤️ this change. So much cleaner.
##########
File path: src/chttpd/src/chttpd_misc.erl
##########
@@ -144,32 +145,24 @@ all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} =
Acc) when
Acc#vacc.req#httpd.path_parts =:= [<<"_all_dbs">>]
->
Prepend = couch_mrview_http:prepend_val(Acc),
- case couch_util:get_value(id, Row) of
- <<"_design", _/binary>> ->
- {ok, Acc};
- DbName ->
- {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend,
?JSON_ENCODE(DbName)]),
- {ok, Acc#vacc{prepend = ",", resp = Resp1}}
- end;
+ DbName = couch_util:get_value(id, Row),
+ {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend,
?JSON_ENCODE(DbName)]),
+ {ok, Acc#vacc{prepend = ",", resp = Resp1}};
all_dbs_info_callback({row, Row}, #vacc{resp = Resp0} = Acc) when
Acc#vacc.req#httpd.path_parts =:= [<<"_dbs_info">>]
->
Prepend = couch_mrview_http:prepend_val(Acc),
- case couch_util:get_value(id, Row) of
- <<"_design", _/binary>> ->
- {ok, Acc};
- DbName ->
- case chttpd_util:get_db_info(DbName) of
- {ok, DbInfo} ->
- Chunk = [Prepend, ?JSON_ENCODE({[{key, DbName}, {info,
{DbInfo}}]})],
- {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, Chunk),
- {ok, Acc#vacc{prepend = ",", resp = Resp1}};
- {error, database_does_not_exist} ->
- {ok, Acc#vacc{resp = Resp0}};
- {error, Reason} ->
- {ok, Resp1} = chttpd:send_delayed_error(Resp0, Reason),
- {stop, Acc#vacc{resp = Resp1}}
- end
+ DbName = couch_util:get_value(id, Row),
+ case chttpd_util:get_db_info(DbName) of
+ {ok, DbInfo} ->
+ Chunk = [Prepend, ?JSON_ENCODE({[{key, DbName}, {info,
{DbInfo}}]})],
+ {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, Chunk),
+ {ok, Acc#vacc{prepend = ",", resp = Resp1}};
+ {error, database_does_not_exist} ->
+ {ok, Acc#vacc{resp = Resp0}};
+ {error, Reason} ->
+ {ok, Resp1} = chttpd:send_delayed_error(Resp0, Reason),
+ {stop, Acc#vacc{resp = Resp1}}
Review comment:
Another awesome simplification.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]