haproxy: fix mixing/invalid merging of stat entries
This commit is contained in:
parent
7a7fcd8e31
commit
9ddd999ed8
1 changed files with 5 additions and 3 deletions
|
@ -40,11 +40,12 @@ defmodule HAHandler.HAProxy do
|
|||
case mapping do
|
||||
%{
|
||||
"id" => id,
|
||||
"proxyId" => proxy_id,
|
||||
"objType" => type,
|
||||
"field" => %{"name" => name},
|
||||
"value" => %{"value" => value},
|
||||
} ->
|
||||
%{:id => id, :type => type, :field => name, :value => value}
|
||||
%{:id => id, :proxy_id => proxy_id, :type => type, :field => name, :value => value}
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
|
@ -54,15 +55,16 @@ defmodule HAHandler.HAProxy do
|
|||
extracted
|
||||
|> List.flatten()
|
||||
|> Enum.group_by(
|
||||
fn mapping -> {mapping.type, mapping.id} end,
|
||||
fn mapping -> {mapping.type, mapping.id, mapping.proxy_id} end,
|
||||
fn mapping -> %{mapping.field => mapping.value} end
|
||||
)
|
||||
|> Enum.map(
|
||||
fn {{type, id}, grouped_mappings} ->
|
||||
fn {{type, id, proxy_id}, grouped_mappings} ->
|
||||
grouped_mappings
|
||||
|> Enum.reduce(fn l, r -> Map.merge(l,r) end)
|
||||
|> Map.put("type", type)
|
||||
|> Map.put("id", id)
|
||||
|> Map.put("proxy_id", proxy_id)
|
||||
end
|
||||
)
|
||||
|> Enum.group_by(
|
||||
|
|
Loading…
Reference in a new issue