diff --git a/lib/decentralised_book_index/metadata/book.ex b/lib/decentralised_book_index/metadata/book.ex index ae58a53..5a3bec0 100644 --- a/lib/decentralised_book_index/metadata/book.ex +++ b/lib/decentralised_book_index/metadata/book.ex @@ -179,11 +179,17 @@ defmodule DecentralisedBookIndex.Metadata.Book do prepare fn query, context -> author = query.arguments.author - {:ok, author_ids} = Metadata.get_author_ids(author) + author_ids = + case Metadata.get_author_ids(author) do + {:ok, ids} -> ids + {:error, _error} -> [] + end - Metadata.Book + query |> Ash.Query.filter(expr(exists(author_roles, author_id in ^author_ids))) end + + pagination offset?: true, default_limit: 10 end read :search do diff --git a/lib/decentralised_book_index_web/live/author_live/show.ex b/lib/decentralised_book_index_web/live/author_live/show.ex index 3ea2c24..ae77e7b 100644 --- a/lib/decentralised_book_index_web/live/author_live/show.ex +++ b/lib/decentralised_book_index_web/live/author_live/show.ex @@ -2,6 +2,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do use DecentralisedBookIndexWeb, :live_view alias DecentralisedBookIndex.Accounts.Role + alias DecentralisedBookIndex.Metadata @impl true def render(assigns) do @@ -96,6 +97,19 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do <% end %> + <%= if not Enum.empty?(@page.results) do %> +