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
@@ -0,0 +1,18 @@
defmodule MusicLibrary.Worker.PruneArtistInfo do
use Oban.Worker, queue: :default, max_attempts: 3
@impl Oban.Worker
def perform(%Oban.Job{args: %{"id" => artist_id}}) do
if MusicLibrary.Artists.exists?(artist_id) do
:ok
else
delete_artist_info(artist_id)
end
end
defp delete_artist_info(artist_id) do
with {_count, nil} <- MusicLibrary.Artists.delete_artist_info(artist_id) do
:ok
end
end
end