Update to refactor AuthorAliasRegistry, its sync and test.

This commit is contained in:
2025-04-10 11:03:49 +03:00
parent a53f0abae5
commit 99f59e6923
3 changed files with 6 additions and 14 deletions
@@ -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!()