|
|
|
@ -45,9 +45,14 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
|
|
|
|
if related_author_id == nil do
|
|
|
|
|
Ash.Changeset.add_error(changeset, :related_author_id, "Related author is empty")
|
|
|
|
|
else
|
|
|
|
|
{:ok, related_author} = DecentralisedBookIndex.Metadata.get_author_by_id(related_author_id)
|
|
|
|
|
|
|
|
|
|
Ash.Changeset.force_change_attribute(changeset, :author_alias_registry_id, related_author.author_alias_registry_id)
|
|
|
|
|
{:ok, related_author} =
|
|
|
|
|
DecentralisedBookIndex.Metadata.get_author_by_id(related_author_id)
|
|
|
|
|
|
|
|
|
|
Ash.Changeset.force_change_attribute(
|
|
|
|
|
changeset,
|
|
|
|
|
:author_alias_registry_id,
|
|
|
|
|
related_author.author_alias_registry_id
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -65,9 +70,22 @@ defmodule DecentralisedBookIndex.Metadata.Author do
|
|
|
|
|
author = query.arguments.author
|
|
|
|
|
|
|
|
|
|
DecentralisedBookIndex.Metadata.Author
|
|
|
|
|
|> Ash.Query.filter(author_alias_registry_id == ^author.author_alias_registry_id
|
|
|
|
|
and id != ^author.id)
|
|
|
|
|
|> Ash.Query.filter(
|
|
|
|
|
author_alias_registry_id == ^author.author_alias_registry_id and
|
|
|
|
|
id != ^author.id
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
read :search do
|
|
|
|
|
argument :name, :ci_string do
|
|
|
|
|
constraints allow_empty?: true
|
|
|
|
|
default ""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
filter expr(contains(name, ^arg(:name)))
|
|
|
|
|
|
|
|
|
|
pagination offset?: true, default_limit: 10
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|