defmodule OhMyExOhIrcd.Scrobbles.Scrobble do
@moduledoc """
Append-only record of an announced scrobble, kept so the web UI can
show the last-N tracks for a channel.
"""
use Ecto.Schema
import Ecto.Changeset
alias OhMyExOhIrcd.Channels.ChannelRecord
schema "scrobbles" do
field :who, :string
field :artist, :string
field :track, :string
field :album, :string
belongs_to :channel, ChannelRecord
timestamps(type: :utc_datetime, updated_at: false)
end
def changeset(record, attrs) do
record
|> cast(attrs, [:channel_id, :who, :artist, :track, :album])
|> validate_required([:channel_id, :who, :artist, :track])
|> validate_length(:who, max: 64)
|> validate_length(:artist, max: 256)
|> validate_length(:track, max: 256)
|> validate_length(:album, max: 256)
|> assoc_constraint(:channel)
end
end
neiam
/oh-my-ex-oh-ircd
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
876 B · text
History
4b6fe3b