Update to refactor AuthorAliasRegistry, its sync and test.
This commit is contained in:
@@ -15,19 +15,11 @@ defmodule DecentralisedBookIndex.Metadata.AuthorAliasRegistry do
|
||||
defaults [:read, :create, :update, :destroy]
|
||||
|
||||
create :sync_create do
|
||||
accept [:id]
|
||||
|
||||
argument :dbi_server_id, :uuid do
|
||||
allow_nil? false
|
||||
end
|
||||
accept [:id, :dbi_server_id]
|
||||
end
|
||||
|
||||
update :sync do
|
||||
accept [:id]
|
||||
|
||||
argument :dbi_server_id, :uuid do
|
||||
allow_nil? false
|
||||
end
|
||||
accept [:id, :dbi_server_id]
|
||||
end
|
||||
|
||||
read :by_id do
|
||||
|
||||
@@ -4,13 +4,13 @@ defmodule DecentralisedBookIndex.Sync.AuthorAliasRegistrySync do
|
||||
|
||||
def create_update(attrs, server_id) do
|
||||
case Metadata.get_author_alias_registry_by_id(attrs.id) do
|
||||
{:ok, author} ->
|
||||
{:ok, alias_registry} ->
|
||||
attrs =
|
||||
attrs
|
||||
|> Map.delete(:id)
|
||||
|> Map.put(:dbi_server_id, server_id)
|
||||
|
||||
author
|
||||
alias_registry
|
||||
|> Ash.Changeset.for_update(:sync, attrs)
|
||||
|> Ash.update!()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user