Load record embedding for wishlisted records
This commit is contained in:
@@ -14,6 +14,7 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
|
|
||||||
alias MusicLibrary.OnlineStoreTemplates
|
alias MusicLibrary.OnlineStoreTemplates
|
||||||
alias MusicLibrary.{Records, RecordSets}
|
alias MusicLibrary.{Records, RecordSets}
|
||||||
|
alias MusicLibrary.Records.Similarity
|
||||||
alias MusicLibrary.RecordSets.RecordSet
|
alias MusicLibrary.RecordSets.RecordSet
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -42,7 +43,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||||
|> assign(:record, record)
|
|> assign(:record, record)
|
||||||
|> assign(:online_store_templates, online_store_templates)
|
|> assign(:online_store_templates, online_store_templates)
|
||||||
|> assign(:record_sets, record_sets)}
|
|> assign(:record_sets, record_sets)
|
||||||
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -152,7 +154,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
def handle_info({MusicLibraryWeb.Components.RecordForm, {:saved, record}}, socket) do
|
def handle_info({MusicLibraryWeb.Components.RecordForm, {:saved, record}}, socket) do
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:record, record)}
|
|> assign(:record, record)
|
||||||
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@@ -160,7 +163,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> put_toast(:info, gettext("Record updated in the background"))
|
|> put_toast(:info, gettext("Record updated in the background"))
|
||||||
|> assign(:record, record)}
|
|> assign(:record, record)
|
||||||
|
|> assign_embedding_text()}
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_title(action, record) do
|
def page_title(action, record) do
|
||||||
@@ -178,6 +182,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
)
|
)
|
||||||
end
|
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(:show), do: gettext("Show")
|
||||||
defp title_segment(:edit), do: gettext("Edit")
|
defp title_segment(:edit), do: gettext("Edit")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -302,13 +302,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<.json_viewer title={gettext("MusicBrainz data")} data={@record.musicbrainz_data} />
|
<.json_viewer title={gettext("MusicBrainz data")} data={@record.musicbrainz_data} />
|
||||||
|
<.text_viewer title={gettext("Record Embedding")} data={@embedding_text} />
|
||||||
|
|
||||||
<.live_component
|
<.live_component
|
||||||
id="record-chat"
|
id="record-chat"
|
||||||
sheet_id="record-chat-sheet"
|
sheet_id="record-chat-sheet"
|
||||||
module={MusicLibraryWeb.Components.RecordChat}
|
module={MusicLibraryWeb.Components.RecordChat}
|
||||||
record={@record}
|
record={@record}
|
||||||
embedding_text={nil}
|
embedding_text={@embedding_text}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<.structured_modal
|
<.structured_modal
|
||||||
|
|||||||
@@ -1666,11 +1666,13 @@ msgid "Running optimize..."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex
|
#: lib/music_library_web/live/collection_live/show.html.heex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/show.html.heex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Record Embedding"
|
msgid "Record Embedding"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.ex
|
#: lib/music_library_web/live/collection_live/show.ex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Not available"
|
msgid "Not available"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -1666,11 +1666,13 @@ msgid "Running optimize..."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex
|
#: lib/music_library_web/live/collection_live/show.html.heex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/show.html.heex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Record Embedding"
|
msgid "Record Embedding"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.ex
|
#: lib/music_library_web/live/collection_live/show.ex
|
||||||
|
#: lib/music_library_web/live/wishlist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "Not available"
|
msgid "Not available"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user