Update Book and Publisher transformers to sync the relationship for DBIServer.
This commit is contained in:
@@ -21,7 +21,9 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformer do
|
|||||||
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
||||||
updated_at: get_in(json_body, ["attributes", "updated_at"]),
|
updated_at: get_in(json_body, ["attributes", "updated_at"]),
|
||||||
# relationship
|
# relationship
|
||||||
publisher_id: get_in(json_body, ["attributes", "publisher_id"])
|
publisher_id: get_in(json_body, ["attributes", "publisher_id"]),
|
||||||
|
# relationship
|
||||||
|
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, attrs}
|
{:ok, attrs}
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformer do
|
|||||||
id: get_in(json_body, ["id"]),
|
id: get_in(json_body, ["id"]),
|
||||||
name: get_in(json_body, ["attributes", "name"]),
|
name: get_in(json_body, ["attributes", "name"]),
|
||||||
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
||||||
updated_at: get_in(json_body, ["attributes", "updated_at"])
|
updated_at: get_in(json_body, ["attributes", "updated_at"]),
|
||||||
|
# relationship
|
||||||
|
dbi_server_id: get_in(json_body, ["attributes", "dbi_server_id"])
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, attrs}
|
{:ok, attrs}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|||||||
json_body = %{
|
json_body = %{
|
||||||
"data" => %{
|
"data" => %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
"cover_image_url" => "/images/book_cover.png",
|
"cover_image_url" => "/images/book_cover.png",
|
||||||
"description" => "A cool book.",
|
"description" => "A cool book.",
|
||||||
"format" => "Paper",
|
"format" => "Paper",
|
||||||
@@ -37,6 +38,8 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|||||||
},
|
},
|
||||||
"meta" => %{}
|
"meta" => %{}
|
||||||
},
|
},
|
||||||
|
"book_editions_registry" => %{"links" => %{}, "meta" => %{}},
|
||||||
|
"dbi_server" => %{"links" => %{}, "meta" => %{}},
|
||||||
"publisher" => %{
|
"publisher" => %{
|
||||||
"links" => %{
|
"links" => %{
|
||||||
"related" =>
|
"related" =>
|
||||||
@@ -67,13 +70,15 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|||||||
published: "2025-03-05",
|
published: "2025-03-05",
|
||||||
publisher_id: "11349865-1b7b-454a-b999-6c4059888a78",
|
publisher_id: "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
title: "Book",
|
title: "Book",
|
||||||
updated_at: "2025-04-01T18:14:25.754055Z"
|
updated_at: "2025-04-01T18:14:25.754055Z",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
||||||
} = book
|
} = book
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a json doesn't contains book information \"data\" attribute" do
|
test "a json doesn't contains book information \"data\" attribute" do
|
||||||
json_body = %{
|
json_body = %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
"cover_image_url" => "/images/book_cover.png",
|
"cover_image_url" => "/images/book_cover.png",
|
||||||
"description" => "A cool book.",
|
"description" => "A cool book.",
|
||||||
"format" => "Paper",
|
"format" => "Paper",
|
||||||
@@ -103,6 +108,8 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|||||||
},
|
},
|
||||||
"meta" => %{}
|
"meta" => %{}
|
||||||
},
|
},
|
||||||
|
"book_editions_registry" => %{"links" => %{}, "meta" => %{}},
|
||||||
|
"dbi_server" => %{"links" => %{}, "meta" => %{}},
|
||||||
"publisher" => %{
|
"publisher" => %{
|
||||||
"links" => %{
|
"links" => %{
|
||||||
"related" =>
|
"related" =>
|
||||||
@@ -127,7 +134,8 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.BookTransformerTest do
|
|||||||
published: "2025-03-05",
|
published: "2025-03-05",
|
||||||
publisher_id: "11349865-1b7b-454a-b999-6c4059888a78",
|
publisher_id: "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
title: "Book",
|
title: "Book",
|
||||||
updated_at: "2025-04-01T18:14:25.754055Z"
|
updated_at: "2025-04-01T18:14:25.754055Z",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
||||||
} = book
|
} = book
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformerTest
|
|||||||
json_body = %{
|
json_body = %{
|
||||||
"data" => %{
|
"data" => %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
"inserted_at" => "2025-03-21T09:20:48.791539Z",
|
"inserted_at" => "2025-03-21T09:20:48.791539Z",
|
||||||
"name" => "Publisher",
|
"name" => "Publisher",
|
||||||
"updated_at" => "2025-03-21T09:20:48.791539Z"
|
"updated_at" => "2025-03-21T09:20:48.791539Z"
|
||||||
@@ -15,7 +16,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformerTest
|
|||||||
"id" => "11349865-1b7b-454a-b999-6c4059888a78",
|
"id" => "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
"links" => %{},
|
"links" => %{},
|
||||||
"meta" => %{},
|
"meta" => %{},
|
||||||
"relationships" => %{},
|
"relationships" => %{"dbi_server" => %{"links" => %{}, "meta" => %{}}},
|
||||||
"type" => "publisher"
|
"type" => "publisher"
|
||||||
},
|
},
|
||||||
"jsonapi" => %{"version" => "1.0"},
|
"jsonapi" => %{"version" => "1.0"},
|
||||||
@@ -32,13 +33,15 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformerTest
|
|||||||
id: "11349865-1b7b-454a-b999-6c4059888a78",
|
id: "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
name: "Publisher",
|
name: "Publisher",
|
||||||
inserted_at: "2025-03-21T09:20:48.791539Z",
|
inserted_at: "2025-03-21T09:20:48.791539Z",
|
||||||
updated_at: "2025-03-21T09:20:48.791539Z"
|
updated_at: "2025-03-21T09:20:48.791539Z",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
||||||
} = publisher
|
} = publisher
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a json doesn't contains publisher information \"data\" attribute" do
|
test "a json doesn't contains publisher information \"data\" attribute" do
|
||||||
json_body = %{
|
json_body = %{
|
||||||
"attributes" => %{
|
"attributes" => %{
|
||||||
|
"dbi_server_id" => "889a323e-d104-4b5d-b276-dad5a9b1da99",
|
||||||
"inserted_at" => "2025-03-21T09:20:48.791539Z",
|
"inserted_at" => "2025-03-21T09:20:48.791539Z",
|
||||||
"name" => "Publisher",
|
"name" => "Publisher",
|
||||||
"updated_at" => "2025-03-21T09:20:48.791539Z"
|
"updated_at" => "2025-03-21T09:20:48.791539Z"
|
||||||
@@ -46,7 +49,7 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformerTest
|
|||||||
"id" => "11349865-1b7b-454a-b999-6c4059888a78",
|
"id" => "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
"links" => %{},
|
"links" => %{},
|
||||||
"meta" => %{},
|
"meta" => %{},
|
||||||
"relationships" => %{},
|
"relationships" => %{"dbi_server" => %{"links" => %{}, "meta" => %{}}},
|
||||||
"type" => "publisher"
|
"type" => "publisher"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +59,8 @@ defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformerTest
|
|||||||
id: "11349865-1b7b-454a-b999-6c4059888a78",
|
id: "11349865-1b7b-454a-b999-6c4059888a78",
|
||||||
name: "Publisher",
|
name: "Publisher",
|
||||||
inserted_at: "2025-03-21T09:20:48.791539Z",
|
inserted_at: "2025-03-21T09:20:48.791539Z",
|
||||||
updated_at: "2025-03-21T09:20:48.791539Z"
|
updated_at: "2025-03-21T09:20:48.791539Z",
|
||||||
|
dbi_server_id: "889a323e-d104-4b5d-b276-dad5a9b1da99"
|
||||||
} = publisher
|
} = publisher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user