diff --git a/lib/music_library/records.ex b/lib/music_library/records.ex index e05d033e..989bbfde 100644 --- a/lib/music_library/records.ex +++ b/lib/music_library/records.ex @@ -320,6 +320,13 @@ defmodule MusicLibrary.Records do ) end + @spec regenerate_artist_embeddings(String.t()) :: :ok + def regenerate_artist_embeddings(artist_id) do + artist_id + |> get_artist_records() + |> Enum.each(&generate_embedding_async/1) + end + @spec resize_cover(Record.t()) :: {:ok, Record.t()} | {:error, term()} def resize_cover(record) do with {:ok, thumb_data} <- Assets.Image.resize(record.cover_data), diff --git a/lib/music_library/worker/fetch_artist_info.ex b/lib/music_library/worker/fetch_artist_info.ex index 7a330d2b..c933270a 100644 --- a/lib/music_library/worker/fetch_artist_info.ex +++ b/lib/music_library/worker/fetch_artist_info.ex @@ -8,15 +8,7 @@ defmodule MusicLibrary.Worker.FetchArtistInfo do {:ok, _artist_info} <- MusicLibrary.Artists.fetch_image(artist_id) do # fetch_lastfm_data returns {:ok, _} even on API errors, so it won't block embeddings MusicLibrary.Artists.fetch_lastfm_data(artist_id) - regenerate_record_embeddings(artist_id) + MusicLibrary.Records.regenerate_artist_embeddings(artist_id) end end - - defp regenerate_record_embeddings(artist_id) do - artist_id - |> MusicLibrary.Records.get_artist_records() - |> Enum.each(fn record -> - MusicLibrary.Records.generate_embedding_async(record) - end) - end end