Prune artist info after deleting the artist's last record

This commit is contained in:
Claudio Ortolina
2025-04-29 18:44:37 +01:00
parent fa49e73385
commit 818a416b1c
3 changed files with 44 additions and 1 deletions
+9 -1
View File
@@ -283,7 +283,15 @@ defmodule MusicLibrary.Records do
end
def delete_record(%Record{} = record) do
Repo.delete(record)
with {:ok, record} <- Repo.delete(record) do
record
|> Record.artist_ids()
|> Enum.each(fn artist_id ->
Artists.prune_artist_info_async(artist_id)
end)
{:ok, record}
end
end
def change_record(%Record{} = record, attrs \\ %{}) do