Skip to content

Commit

Permalink
Update feed stream queue to skip anything before today (2024/09/09) i…
Browse files Browse the repository at this point in the history
…n preparation for backfilling new bucket data
  • Loading branch information
skanderm committed Sep 9, 2024
1 parent 35282b8 commit 30e4380
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion server/lib/orcasite/radio/feed_stream_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ defmodule Orcasite.Radio.FeedStreamQueue do
end
end)
|> Enum.flat_map(fn %{"s3" => %{"object" => %{"key" => object_path}}} ->
if String.ends_with?(object_path, ".m3u8") do
if String.ends_with?(object_path, ".m3u8") and
select_recent_timestamp(object_path, ~U[2024-09-09 00:00:00Z]) do
[%{m3u8_path: object_path}]
else
[]
Expand All @@ -71,4 +72,22 @@ defmodule Orcasite.Radio.FeedStreamQueue do

messages
end

def select_recent_timestamp(object_path, after_date) do
with {:path, %{"timestamp" => timestamp}} <-
{:path,
Regex.named_captures(
~r|(?<node_name>[^/]+)/hls/(?<timestamp>[^/]+)/live.m3u8|,
object_path
)},
timestamp_time =
timestamp
|> String.to_integer()
|> DateTime.from_unix!(),
:gt <- DateTime.compare(timestamp_time, after_date) do
true
else
_ -> false
end
end
end

0 comments on commit 30e4380

Please sign in to comment.