refactor: simplify the code with maps:map/2
Thanks @thalesmg for the suggestion
This commit is contained in:
parent
4b540e3bd0
commit
88c96e26de
|
@ -1499,14 +1499,11 @@ maybe_reply(Actions, From, Reply) ->
|
||||||
|
|
||||||
-spec data_record_to_external_map(data()) -> resource_data().
|
-spec data_record_to_external_map(data()) -> resource_data().
|
||||||
data_record_to_external_map(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 =
|
AddedChannelsWithoutConfigs =
|
||||||
maps:from_list(AddedChannelsListWithoutConfigs),
|
maps:map(
|
||||||
|
fun(_ChanID, Status) -> maps:remove(config, Status) end,
|
||||||
|
Data#data.added_channels
|
||||||
|
),
|
||||||
#{
|
#{
|
||||||
id => Data#data.id,
|
id => Data#data.id,
|
||||||
error => external_error(Data#data.error),
|
error => external_error(Data#data.error),
|
||||||
|
|
Loading…
Reference in New Issue