Added basic Oban job for indexing

This commit is contained in:
Kieran Eglin 2024-01-25 08:53:29 -08:00
parent b661585a2a
commit da1fd98e83
No known key found for this signature in database
GPG key ID: 193984967FCF432D
2 changed files with 19 additions and 1 deletions

View file

@ -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
#

View file

@ -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