Skip to content

Commit

Permalink
refactor: simplify the code with maps:map/2
Browse files Browse the repository at this point in the history
Thanks @thalesmg for the suggestion
  • Loading branch information
kjellwinblad committed May 22, 2024
1 parent 4b540e3 commit 88c96e2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions apps/emqx_resource/src/emqx_resource_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1499,14 +1499,11 @@ maybe_reply(Actions, From, Reply) ->

-spec data_record_to_external_map(data()) -> resource_data().
data_record_to_external_map(Data) ->
AddedChannelsList = maps:to_list(Data#data.added_channels),
AddedChannelsListWithoutConfigs =
[
{ChanID, maps:remove(config, Status)}
|| {ChanID, Status} <- AddedChannelsList
],
AddedChannelsWithoutConfigs =
maps:from_list(AddedChannelsListWithoutConfigs),
maps:map(
fun(_ChanID, Status) -> maps:remove(config, Status) end,
Data#data.added_channels
),
#{
id => Data#data.id,
error => external_error(Data#data.error),
Expand Down

0 comments on commit 88c96e2

Please sign in to comment.