Skip to content

Commit

Permalink
Merge branch 'main' into skander/subscriber-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm authored Aug 31, 2023
2 parents d7b83b9 + a35f377 commit ee03478
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
39 changes: 37 additions & 2 deletions server/lib/orcasite/radio/detection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,34 @@ defmodule Orcasite.Radio.Detection do
default_limit 100
end

prepare build(load: [:uuid])
prepare build(load: [:uuid], sort: [inserted_at: :desc])
end

read :read do
primary? true
prepare build(load: [:uuid])
prepare build(load: [:uuid], sort: [inserted_at: :desc])
end

read :by_detection_type do
pagination do
offset? true
countable true
default_limit 100
end

argument :detection_type, :atom do
allow_nil? false
constraints one_of: [:orca, :vessel, :other]
end

prepare build(load: [:uuid], sort: [inserted_at: :desc])

filter expr(
fragment(
"description ilike ?",
"[" <> ^arg(:detection_type) <> "]%"
)
)
end

update :update do
Expand Down Expand Up @@ -171,6 +193,19 @@ defmodule Orcasite.Radio.Detection do
end
end

admin do
table_columns [
:id,
:feed_id,
:playlist_timestamp,
:player_offset,
:listener_count,
:description,
:candidate_id,
:inserted_at
]
end

defp datetime_min(time_1, time_2) do
case DateTime.compare(time_1, time_2) do
:lt -> time_1
Expand Down
5 changes: 3 additions & 2 deletions server/lib/orcasite/radio/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Orcasite.Radio.Feed do
data_layer: AshPostgres.DataLayer

attributes do
uuid_attribute :id, prefix: "feed"
uuid_attribute(:id, prefix: "feed")

attribute :name, :string, allow_nil?: false
attribute :node_name, :string, allow_nil?: false
Expand Down Expand Up @@ -76,7 +76,7 @@ defmodule Orcasite.Radio.Feed do
Orcasite.Types.LatLng,
{Orcasite.Radio.Calculations.LatLng,
keys: [:location_point], select: [:location_point]},
allow_nil?: false
allow_nil?: false

calculate :lat_lng_string,
:string,
Expand All @@ -96,6 +96,7 @@ defmodule Orcasite.Radio.Feed do
table_columns [:id, :name, :slug, :node_name, :location_point]

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

form do
field :intro_html, type: :long_text
end
Expand Down

0 comments on commit ee03478

Please sign in to comment.