From 62be4c9165862fbec3ff4209c6cb47f750f1ce79 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Thu, 10 Apr 2025 11:15:32 +0300 Subject: [PATCH] Update to refactor Author and its sync. --- lib/decentralised_book_index/metadata/author.ex | 8 -------- lib/decentralised_book_index/sync/sync/author_sync.ex | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/decentralised_book_index/metadata/author.ex b/lib/decentralised_book_index/metadata/author.ex index b74ad28..b2f5134 100644 --- a/lib/decentralised_book_index/metadata/author.ex +++ b/lib/decentralised_book_index/metadata/author.ex @@ -68,7 +68,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do :name, :description, :avatar_url, - :dbi_server_id, :author_alias_registry_id, :inserted_at, :updated_at, @@ -76,9 +75,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do ] 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) if registry_id == nil do @@ -146,7 +142,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do :name, :description, :avatar_url, - :dbi_server_id, :author_alias_registry_id, :inserted_at, :updated_at, @@ -154,9 +149,6 @@ defmodule DecentralisedBookIndex.Metadata.Author do ] 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) if registry_id == nil do diff --git a/lib/decentralised_book_index/sync/sync/author_sync.ex b/lib/decentralised_book_index/sync/sync/author_sync.ex index 144aaf3..4671572 100644 --- a/lib/decentralised_book_index/sync/sync/author_sync.ex +++ b/lib/decentralised_book_index/sync/sync/author_sync.ex @@ -23,8 +23,8 @@ defmodule DecentralisedBookIndex.Sync.AuthorSync do {:error, %Ash.Error.Query.NotFound{}} -> attrs = attrs - |> Map.put(:dbi_server_id, server_id) |> update_registry(registry_info) + |> Map.put(:dbi_server_id, server_id) Author |> 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) if id != nil do - Map.get(%{c: 1, b: 3}, :a, nil) - %{id: id} |> AuthorAliasRegistrySync.create_update(server_id)