Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/radiator/podcasts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ defmodule Radiator.Podcasts do

resource Radiator.Podcasts.Chapter
resource Radiator.Podcasts.License
resource Radiator.Podcasts.Transcript
resource Radiator.Podcasts.Track
resource Radiator.Podcasts.Person
resource Radiator.Podcasts.Persona
resource Radiator.Podcasts.EpisodePersona
resource Radiator.Podcasts.Role
end
end
2 changes: 2 additions & 0 deletions lib/radiator/podcasts/episode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ defmodule Radiator.Podcasts.Episode do
public? true
allow_nil? false
end

has_many :tracks, Radiator.Podcasts.Track
end

identities do
Expand Down
37 changes: 37 additions & 0 deletions lib/radiator/podcasts/episode_persona.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
defmodule Radiator.Podcasts.EpisodePersona do

Check warning on line 1 in lib/radiator/podcasts/episode_persona.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "episode_personas"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

timestamps()
end

relationships do
belongs_to :episode, Radiator.Podcasts.Episode do
allow_nil? false
end

belongs_to :persona, Radiator.Podcasts.Persona do
allow_nil? false
end

relationships do
belongs_to :role, Radiator.Podcasts.Role do
allow_nil? true
end
end
end

identities do
identity :one_persona_per_episode, [:episode_id, :persona_id]
end
end
48 changes: 48 additions & 0 deletions lib/radiator/podcasts/person.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
defmodule Radiator.Podcasts.Person do

Check warning on line 1 in lib/radiator/podcasts/person.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "people"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

attribute :real_name, :string do
allow_nil? false
public? false
end

attribute :nickname, :string do
allow_nil? true
public? false
end

attribute :email, :string do
allow_nil? true
public? false
end

attribute :telephone, :string do
allow_nil? true
public? false

constraints match: ~r/^\+[1-9]\d{1,15}$/
end

timestamps()
end

relationships do
has_many :personas, Radiator.Podcasts.Persona

has_one :default_persona, Radiator.Podcasts.Persona do
destination_attribute :person_id
filter expr(default? == true)
end
end
end
51 changes: 51 additions & 0 deletions lib/radiator/podcasts/persona.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
defmodule Radiator.Podcasts.Persona do

Check warning on line 1 in lib/radiator/podcasts/persona.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "personas"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

attribute :public_name, :string do
allow_nil? false
public? true
end

attribute :slug, :string do
allow_nil? false
public? false
end

attribute :description, :string do
allow_nil? true
public? true
end

attribute :avatar_png, :binary do
allow_nil? true
public? true
end

attribute :default?, :boolean do
public? false
end
end

relationships do
belongs_to :person, Radiator.Podcasts.Person
end

identities do
identity :slug, [:slug]

# identity :one_default_per_person, [:person_id] do
# where expr(default? == true)
# end
end
end
2 changes: 1 addition & 1 deletion lib/radiator/podcasts/podcast.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Radiator.Podcasts.Podcast do
data_layer: AshPostgres.DataLayer

postgres do
table "shows"
table "podcasts"
repo Radiator.Repo
end

Expand Down
21 changes: 21 additions & 0 deletions lib/radiator/podcasts/role.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defmodule Radiator.Podcasts.Role do

Check warning on line 1 in lib/radiator/podcasts/role.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "roles"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

timestamps()
end

relationships do
has_many :episode_personas, Radiator.Podcasts.EpisodePersona
end
end
31 changes: 31 additions & 0 deletions lib/radiator/podcasts/track.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule Radiator.Podcasts.Track do

Check warning on line 1 in lib/radiator/podcasts/track.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "tracks"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

attribute :name, :string do
allow_nil? false
public? false
end

timestamps()
end

relationships do
has_many :transcripts, Radiator.Podcasts.Transcript
belongs_to :episode, Radiator.Podcasts.Episode

belongs_to :persona, Radiator.Podcasts.Persona do
allow_nil? true
end
end
end
43 changes: 43 additions & 0 deletions lib/radiator/podcasts/transcript.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
defmodule Radiator.Podcasts.Transcript do

Check warning on line 1 in lib/radiator/podcasts/transcript.ex

View workflow job for this annotation

GitHub Actions / Build & Test

Modules should have a @moduledoc tag.
use Ash.Resource,
otp_app: :radiator,
domain: Radiator.Podcasts,
data_layer: AshPostgres.DataLayer

postgres do
table "transcripts"
repo Radiator.Repo
end

attributes do
uuid_primary_key :id

attribute :text, :string do
allow_nil? false
public? true
end

attribute :start_time_ms, :integer do
allow_nil? false
public? true
end

attribute :end_time_ms, :integer do
allow_nil? false
public? true
end

timestamps()
end

relationships do
belongs_to :track, Radiator.Podcasts.Track
end

validations do
validate compare(:start_time_ms,
less_than: :end_time_ms,
message: "Start time must be before end time"
)
end
end
4 changes: 2 additions & 2 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
elixir = "1.18.4-otp-27"
erlang = "27.3.4.3"
elixir = "1.19.2-otp-28"
erlang = "28.1.1"
Loading
Loading