Extract artist_changeset/2 to Artist module

This commit is contained in:
Claudio Ortolina
2025-01-24 14:28:52 +00:00
parent abc48cfdf3
commit 38f7bf70bf
2 changed files with 8 additions and 7 deletions
+8
View File
@@ -1,10 +1,18 @@
defmodule MusicLibrary.Records.Artist do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:musicbrainz_id, :binary_id, autogenerate: false}
embedded_schema do
field :name, :string
field :sort_name, :string
field :disambiguation, :string
end
def changeset(artist, attrs) do
artist
|> cast(attrs, [:name, :sort_name, :disambiguation, :musicbrainz_id])
|> validate_required([:name, :sort_name, :musicbrainz_id])
end
end
-7
View File
@@ -71,13 +71,6 @@ defmodule MusicLibrary.Records.Record do
Enum.count(record.included_release_group_ids)
end
@doc false
def artist_changeset(artist, attrs) do
artist
|> cast(attrs, [:name, :sort_name, :disambiguation, :musicbrainz_id])
|> validate_required([:name, :sort_name, :musicbrainz_id])
end
def add_artists(record, artists_attrs) do
record
|> change()