From b9ee7a6ce92b1e08c9121c3ecd75eeaa333e50f7 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sun, 22 Feb 2026 15:14:38 +0000 Subject: [PATCH] Load record embedding for wishlisted records --- .../live/wishlist_live/show.ex | 17 ++++++++++++++--- .../live/wishlist_live/show.html.heex | 3 ++- priv/gettext/default.pot | 2 ++ priv/gettext/en/LC_MESSAGES/default.po | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex index 6158ffe8..29e5904d 100644 --- a/lib/music_library_web/live/wishlist_live/show.ex +++ b/lib/music_library_web/live/wishlist_live/show.ex @@ -14,6 +14,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do alias MusicLibrary.OnlineStoreTemplates alias MusicLibrary.{Records, RecordSets} + alias MusicLibrary.Records.Similarity alias MusicLibrary.RecordSets.RecordSet @impl true @@ -42,7 +43,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do |> assign(:page_title, page_title(socket.assigns.live_action, record)) |> assign(:record, record) |> assign(:online_store_templates, online_store_templates) - |> assign(:record_sets, record_sets)} + |> assign(:record_sets, record_sets) + |> assign_embedding_text()} end @impl true @@ -152,7 +154,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do def handle_info({MusicLibraryWeb.Components.RecordForm, {:saved, record}}, socket) do {:noreply, socket - |> assign(:record, record)} + |> assign(:record, record) + |> assign_embedding_text()} end @impl true @@ -160,7 +163,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do {:noreply, socket |> put_toast(:info, gettext("Record updated in the background")) - |> assign(:record, record)} + |> assign(:record, record) + |> assign_embedding_text()} end def page_title(action, record) do @@ -178,6 +182,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do ) end + defp assign_embedding_text(socket) do + case Similarity.get_embedding_text(socket.assigns.record.id) do + {:ok, text} -> assign(socket, :embedding_text, text) + {:error, _reason} -> assign(socket, :embedding_text, gettext("Not available")) + end + end + defp title_segment(:show), do: gettext("Show") defp title_segment(:edit), do: gettext("Edit") end diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex index 758d610f..900c39cb 100644 --- a/lib/music_library_web/live/wishlist_live/show.html.heex +++ b/lib/music_library_web/live/wishlist_live/show.html.heex @@ -302,13 +302,14 @@ <.json_viewer title={gettext("MusicBrainz data")} data={@record.musicbrainz_data} /> + <.text_viewer title={gettext("Record Embedding")} data={@embedding_text} /> <.live_component id="record-chat" sheet_id="record-chat-sheet" module={MusicLibraryWeb.Components.RecordChat} record={@record} - embedding_text={nil} + embedding_text={@embedding_text} /> <.structured_modal diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index b4d51f74..f02c1bd8 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -1666,11 +1666,13 @@ msgid "Running optimize..." msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex +#: lib/music_library_web/live/wishlist_live/show.html.heex #, elixir-autogen, elixir-format msgid "Record Embedding" msgstr "" #: lib/music_library_web/live/collection_live/show.ex +#: lib/music_library_web/live/wishlist_live/show.ex #, elixir-autogen, elixir-format msgid "Not available" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index f93674d0..1770c3e4 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -1666,11 +1666,13 @@ msgid "Running optimize..." msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex +#: lib/music_library_web/live/wishlist_live/show.html.heex #, elixir-autogen, elixir-format msgid "Record Embedding" msgstr "" #: lib/music_library_web/live/collection_live/show.ex +#: lib/music_library_web/live/wishlist_live/show.ex #, elixir-autogen, elixir-format, fuzzy msgid "Not available" msgstr ""