Skip to content

Commit

Permalink
Merge branch 'main' into dependabot-config
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcretu authored Jul 27, 2024
2 parents a6b26a0 + 65a53a9 commit cb23eca
Show file tree
Hide file tree
Showing 9 changed files with 756 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/lib/orcasite/radio/candidate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ defmodule Orcasite.Radio.Candidate do

update :update do
primary? true
accept [:min_time, :max_time, :detection_count, :visible]
accept [:min_time, :max_time, :detection_count, :visible, :category]
end

update :cancel_notifications do
Expand Down
1 change: 1 addition & 0 deletions server/lib/orcasite/radio/detection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ defmodule Orcasite.Radio.Detection do
primary? true
argument :candidate, :map
require_atomic? false
accept [:description, :visible, :category]

change manage_relationship(:candidate, type: :append)
end
Expand Down
25 changes: 20 additions & 5 deletions server/lib/orcasite/radio/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule Orcasite.Radio.Feed do
index [:node_name]
index [:visible]
index [:slug]
index [:dataplicity_id]
end

migration_defaults id: "fragment(\"uuid_generate_v7()\")"
Expand All @@ -36,6 +37,7 @@ defmodule Orcasite.Radio.Feed do
attribute :bucket, :string, public?: true
attribute :bucket_region, :string, public?: true
attribute :cloudfront_url, :string, public?: true
attribute :dataplicity_id, :string, public?: true

create_timestamp :inserted_at
update_timestamp :updated_at
Expand Down Expand Up @@ -65,10 +67,21 @@ defmodule Orcasite.Radio.Feed do
public?: true
end

aggregates do
exists :online, :feed_segments do
public? true
filter expr(inserted_at > ago(30, :second))
end
end


relationships do
has_many :feed_streams, Orcasite.Radio.FeedStream do
public? true
end
has_many :feed_segments, Orcasite.Radio.FeedSegment do
public? true
end
end

policies do
Expand All @@ -86,12 +99,12 @@ defmodule Orcasite.Radio.Feed do

read :read do
primary? true
prepare build(load: [:lat_lng, :lat_lng_string])
prepare build(load: [:lat_lng, :lat_lng_string, :online])
end

read :index do
filter expr(visible)
prepare build(load: [:lat_lng, :lat_lng_string])
prepare build(load: [:lat_lng, :lat_lng_string, :online])
end

read :get_by_slug do
Expand All @@ -114,7 +127,8 @@ defmodule Orcasite.Radio.Feed do
:visible,
:bucket,
:bucket_region,
:cloudfront_url
:cloudfront_url,
:dataplicity_id
]

argument :lat_lng_string, :string do
Expand All @@ -137,7 +151,8 @@ defmodule Orcasite.Radio.Feed do
:visible,
:bucket,
:bucket_region,
:cloudfront_url
:cloudfront_url,
:dataplicity_id
]

argument :lat_lng_string, :string do
Expand All @@ -149,7 +164,7 @@ defmodule Orcasite.Radio.Feed do
end

admin do
table_columns [:id, :name, :slug, :node_name, :location_point, :visible]
table_columns [:id, :name, :slug, :node_name, :location_point, :visible, :online]

format_fields location_point: {Jason, :encode!, []}, lat_lng: {Jason, :encode!, []}

Expand Down
1 change: 1 addition & 0 deletions server/lib/orcasite/radio/feed_segment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule Orcasite.Radio.FeedSegment do
index [:feed_id]
index [:feed_stream_id]
index [:bucket]
index [:inserted_at]
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Orcasite.Repo.Migrations.AddInsertedAtIndexToFeedSegments do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
create index(:feed_segments, [:inserted_at])
end

def down do
drop_if_exists index(:feed_segments, [:inserted_at])
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Orcasite.Repo.Migrations.AddDataplicityIdToFeeds do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
alter table(:feeds) do
add :dataplicity_id, :text
end

create index(:feeds, [:dataplicity_id])
end

def down do
drop_if_exists index(:feeds, [:dataplicity_id])

alter table(:feeds) do
remove :dataplicity_id
end
end
end
Loading

0 comments on commit cb23eca

Please sign in to comment.