Skip to content

Commit

Permalink
Create populate function for past feed_streams
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed May 24, 2024
1 parent fbdfbd9 commit ace811d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/lib/orcasite/global_setup.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Orcasite.GlobalSetup do
def populate_feed_streams do
Orcasite.Radio.Feed
|> Ash.Query.for_read(:read)
|> Orcasite.Radio.read!()
|> Enum.map(fn feed ->
with {:ok, %{timestamps: timestamps}} <- Orcasite.Radio.AwsClient.list_timestamps(feed) do
timestamps
|> Enum.map(&%{feed: feed, playlist_timestamp: &1})
|> Orcasite.Radio.bulk_create(Orcasite.Radio.FeedStream, :create)
end
end)
end
end
9 changes: 9 additions & 0 deletions server/lib/orcasite/radio/feed_stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ defmodule Orcasite.Radio.FeedStream do
primary? true
upsert? true
upsert_identity :feed_stream_timestamp
upsert_fields [
:start_time,
:end_time,
:duration,
:bucket,
:bucket_region,
:cloudfront_url,
:playlist_timestamp
]

accept [
:start_time,
Expand Down

0 comments on commit ace811d

Please sign in to comment.