Update to refactor Author and its sync.

dev
KKlochko 3 months ago
parent 99f59e6923
commit 62be4c9165

@ -68,7 +68,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do
:name, :name,
:description, :description,
:avatar_url, :avatar_url,
:dbi_server_id,
:author_alias_registry_id, :author_alias_registry_id,
:inserted_at, :inserted_at,
:updated_at, :updated_at,
@ -76,9 +75,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do
] ]
change fn changeset, _ -> change fn changeset, _ ->
server_id = Ash.Changeset.get_attribute(changeset, :dbi_server)
Ash.Changeset.force_change_attribute(changeset, :author_alias_registry_id, server_id)
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id) registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
if registry_id == nil do if registry_id == nil do
@ -146,7 +142,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do
:name, :name,
:description, :description,
:avatar_url, :avatar_url,
:dbi_server_id,
:author_alias_registry_id, :author_alias_registry_id,
:inserted_at, :inserted_at,
:updated_at, :updated_at,
@ -154,9 +149,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do
] ]
change fn changeset, _ -> change fn changeset, _ ->
server_id = Ash.Changeset.get_attribute(changeset, :dbi_server)
Ash.Changeset.force_change_attribute(changeset, :author_alias_registry_id, server_id)
registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id) registry_id = Ash.Changeset.get_attribute(changeset, :author_alias_registry_id)
if registry_id == nil do if registry_id == nil do

@ -23,8 +23,8 @@ defmodule DecentralisedBookIndex.Sync.AuthorSync do
{:error, %Ash.Error.Query.NotFound{}} -> {:error, %Ash.Error.Query.NotFound{}} ->
attrs = attrs =
attrs attrs
|> Map.put(:dbi_server_id, server_id)
|> update_registry(registry_info) |> update_registry(registry_info)
|> Map.put(:dbi_server_id, server_id)
Author Author
|> Ash.Changeset.for_create(:sync_create, attrs) |> Ash.Changeset.for_create(:sync_create, attrs)
@ -38,8 +38,6 @@ defmodule DecentralisedBookIndex.Sync.AuthorSync do
id = Map.get(attrs, :author_alias_registry_id, nil) id = Map.get(attrs, :author_alias_registry_id, nil)
if id != nil do if id != nil do
Map.get(%{c: 1, b: 3}, :a, nil)
%{id: id} %{id: id}
|> AuthorAliasRegistrySync.create_update(server_id) |> AuthorAliasRegistrySync.create_update(server_id)

Loading…
Cancel
Save