Update the AuthorTransformer to sync all attributes and relationships.
This commit is contained in:
@@ -13,7 +13,11 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformer do
|
|||||||
name: get_in(json_body, ["attributes", "name"]),
|
name: get_in(json_body, ["attributes", "name"]),
|
||||||
description: get_in(json_body, ["attributes", "description"]),
|
description: get_in(json_body, ["attributes", "description"]),
|
||||||
avatar_url: get_in(json_body, ["attributes", "avatar_url"]),
|
avatar_url: get_in(json_body, ["attributes", "avatar_url"]),
|
||||||
author_alias_registry_id: get_in(json_body, ["attributes", "author_alias_registry_id"])
|
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
||||||
|
updated_at: get_in(json_body, ["attributes", "updated_at"]),
|
||||||
|
# relationship
|
||||||
|
author_alias_registry_id: get_in(json_body, ["attributes", "author_alias_registry_id"]),
|
||||||
|
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, attrs}
|
{:ok, attrs}
|
||||||
|
|||||||
@@ -8,15 +8,21 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformerTest do
|
|||||||
json_body = %{
|
json_body = %{
|
||||||
"data" => %{
|
"data" => %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
"description" => "Something",
|
"author_alias_registry_id" => "1320a6fe-b311-45ac-bbaa-39cf29c44624",
|
||||||
"name" => "Author",
|
|
||||||
"avatar_url" => "/images/avatar.png",
|
"avatar_url" => "/images/avatar.png",
|
||||||
"author_alias_registry_id" => "1320a6fe-b311-45ac-bbaa-39cf29c44624"
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
|
"description" => "Something",
|
||||||
|
"inserted_at" => "2025-03-25T19:19:15.187456Z",
|
||||||
|
"name" => "Author",
|
||||||
|
"updated_at" => "2025-03-26T10:16:16.124581Z"
|
||||||
},
|
},
|
||||||
"id" => "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
"id" => "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
||||||
"links" => %{},
|
"links" => %{},
|
||||||
"meta" => %{},
|
"meta" => %{},
|
||||||
"relationships" => %{},
|
"relationships" => %{
|
||||||
|
"author_alias_registry" => %{"links" => %{}, "meta" => %{}},
|
||||||
|
"dbi_server" => %{"links" => %{}, "meta" => %{}}
|
||||||
|
},
|
||||||
"type" => "author"
|
"type" => "author"
|
||||||
},
|
},
|
||||||
"jsonapi" => %{"version" => "1.0"},
|
"jsonapi" => %{"version" => "1.0"},
|
||||||
@@ -34,22 +40,31 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformerTest do
|
|||||||
name: "Author",
|
name: "Author",
|
||||||
description: "Something",
|
description: "Something",
|
||||||
avatar_url: "/images/avatar.png",
|
avatar_url: "/images/avatar.png",
|
||||||
author_alias_registry_id: "1320a6fe-b311-45ac-bbaa-39cf29c44624"
|
author_alias_registry_id: "1320a6fe-b311-45ac-bbaa-39cf29c44624",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
|
inserted_at: "2025-03-25T19:19:15.187456Z",
|
||||||
|
updated_at: "2025-03-26T10:16:16.124581Z"
|
||||||
} = author
|
} = author
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a json doesn't contains author information \"data\" attribute" do
|
test "a json doesn't contains author information \"data\" attribute" do
|
||||||
json_body = %{
|
json_body = %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
"description" => "Something",
|
"author_alias_registry_id" => "1320a6fe-b311-45ac-bbaa-39cf29c44624",
|
||||||
"name" => "Author",
|
|
||||||
"avatar_url" => "/images/avatar.png",
|
"avatar_url" => "/images/avatar.png",
|
||||||
"author_alias_registry_id" => "1320a6fe-b311-45ac-bbaa-39cf29c44624"
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
|
"description" => "Something",
|
||||||
|
"inserted_at" => "2025-03-25T19:19:15.187456Z",
|
||||||
|
"name" => "Author",
|
||||||
|
"updated_at" => "2025-03-26T10:16:16.124581Z"
|
||||||
},
|
},
|
||||||
"id" => "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
"id" => "889a323e-d104-4b5d-b276-dad5a9b1da9d",
|
||||||
"links" => %{},
|
"links" => %{},
|
||||||
"meta" => %{},
|
"meta" => %{},
|
||||||
"relationships" => %{},
|
"relationships" => %{
|
||||||
|
"author_alias_registry" => %{"links" => %{}, "meta" => %{}},
|
||||||
|
"dbi_server" => %{"links" => %{}, "meta" => %{}}
|
||||||
|
},
|
||||||
"type" => "author"
|
"type" => "author"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +75,10 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformerTest do
|
|||||||
name: "Author",
|
name: "Author",
|
||||||
description: "Something",
|
description: "Something",
|
||||||
avatar_url: "/images/avatar.png",
|
avatar_url: "/images/avatar.png",
|
||||||
author_alias_registry_id: "1320a6fe-b311-45ac-bbaa-39cf29c44624"
|
author_alias_registry_id: "1320a6fe-b311-45ac-bbaa-39cf29c44624",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
|
inserted_at: "2025-03-25T19:19:15.187456Z",
|
||||||
|
updated_at: "2025-03-26T10:16:16.124581Z"
|
||||||
} = author
|
} = author
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user