Prune artist info after deleting the artist's last record
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user