Added basic Oban job for indexing
This commit is contained in:
parent
b661585a2a
commit
da1fd98e83
2 changed files with 19 additions and 1 deletions
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
17
lib/pinchflat/workers/media_indexing_worker.ex
Normal file
17
lib/pinchflat/workers/media_indexing_worker.ex
Normal 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
|
||||
Loading…
Reference in a new issue