diff --git a/config/config.exs b/config/config.exs index 60b1bca..13647a2 100644 --- a/config/config.exs +++ b/config/config.exs @@ -30,7 +30,8 @@ config :pinchflat, PinchflatWeb.Endpoint, config :pinchflat, Oban, repo: Pinchflat.Repo, plugins: [Oban.Plugins.Pruner], - queues: [default: 10] + # TODO: consider making this an env var or something? + queues: [default: 10, media_indexing: 2, media_fetching: 2] # Configures the mailer # diff --git a/lib/pinchflat/workers/media_indexing_worker.ex b/lib/pinchflat/workers/media_indexing_worker.ex new file mode 100644 index 0000000..01bed11 --- /dev/null +++ b/lib/pinchflat/workers/media_indexing_worker.ex @@ -0,0 +1,17 @@ +defmodule Pinchflat.Workers.MediaIndexingWorker do + use Oban.Worker, queue: :media_indexing + + alias Pinchflat.MediaSource + + @impl Oban.Worker + # This `channel_id` is the ID of the channel _record_ in + # the database, not the ID of the channel on YouTube. + # TODO: test + def perform(%Oban.Job{args: %{"channel_id" => channel_id}}) do + channel_id + |> MediaSource.get_channel!() + |> MediaSource.index_media_items() + + :ok + end +end