Fix data transformers to remove a nil value of dbi_server for syncing.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Map.put_new don't update nil value, because the key exists.
This commit is contained in:
@@ -20,6 +20,10 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformer do
|
||||
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||
}
|
||||
|
||||
{:ok, attrs}
|
||||
if is_nil(attrs[:dbi_server_id]) do
|
||||
{:ok, attrs |> Map.delete(:dbi_server_id)}
|
||||
else
|
||||
{:ok, attrs}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,6 +26,10 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformer do
|
||||
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||
}
|
||||
|
||||
{:ok, attrs}
|
||||
if is_nil(attrs[:dbi_server_id]) do
|
||||
{:ok, attrs |> Map.delete(:dbi_server_id)}
|
||||
else
|
||||
{:ok, attrs}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +18,10 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.DBIServerTransformer do
|
||||
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||
}
|
||||
|
||||
{:ok, attrs}
|
||||
if is_nil(attrs[:dbi_server_id]) do
|
||||
{:ok, attrs |> Map.delete(:dbi_server_id)}
|
||||
else
|
||||
{:ok, attrs}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,10 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformer do
|
||||
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||
}
|
||||
|
||||
{:ok, attrs}
|
||||
if is_nil(attrs[:dbi_server_id]) do
|
||||
{:ok, attrs |> Map.delete(:dbi_server_id)}
|
||||
else
|
||||
{:ok, attrs}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user