renamed ChannelTasks

This commit is contained in:
Kieran Eglin 2024-02-02 10:14:20 -08:00
parent 2377371d8c
commit d822aaa899
No known key found for this signature in database
GPG key ID: 193984967FCF432D
3 changed files with 11 additions and 11 deletions

View file

@ -8,7 +8,7 @@ defmodule Pinchflat.MediaSource do
alias Pinchflat.Tasks alias Pinchflat.Tasks
alias Pinchflat.Media alias Pinchflat.Media
alias Pinchflat.Tasks.ChannelTasks alias Pinchflat.Tasks.SourceTasks
alias Pinchflat.MediaSource.Source alias Pinchflat.MediaSource.Source
alias Pinchflat.MediaClient.ChannelDetails alias Pinchflat.MediaClient.ChannelDetails
@ -65,7 +65,7 @@ defmodule Pinchflat.MediaSource do
media if the indexing frequency has been changed. media if the indexing frequency has been changed.
Existing indexing tasks will be cancelled if the indexing frequency has been Existing indexing tasks will be cancelled if the indexing frequency has been
changed (logic in `ChannelTasks.kickoff_indexing_task`) changed (logic in `SourceTasks.kickoff_indexing_task`)
Returns {:ok, %Source{}} | {:error, %Ecto.Changeset{}} Returns {:ok, %Source{}} | {:error, %Ecto.Changeset{}}
""" """
@ -150,13 +150,13 @@ defmodule Pinchflat.MediaSource do
case changeset.data do case changeset.data do
# If the changeset is new (not persisted), attempt indexing no matter what # If the changeset is new (not persisted), attempt indexing no matter what
%{__meta__: %{state: :built}} -> %{__meta__: %{state: :built}} ->
ChannelTasks.kickoff_indexing_task(channel) SourceTasks.kickoff_indexing_task(channel)
# If the record has been persisted, only attempt indexing if the # If the record has been persisted, only attempt indexing if the
# indexing frequency has been changed # indexing frequency has been changed
%{__meta__: %{state: :loaded}} -> %{__meta__: %{state: :loaded}} ->
if Map.has_key?(changeset.changes, :index_frequency_minutes) do if Map.has_key?(changeset.changes, :index_frequency_minutes) do
ChannelTasks.kickoff_indexing_task(channel) SourceTasks.kickoff_indexing_task(channel)
end end
end end
end end

View file

@ -1,4 +1,4 @@
defmodule Pinchflat.Tasks.ChannelTasks do defmodule Pinchflat.Tasks.SourceTasks do
@moduledoc """ @moduledoc """
This module contains methods for managing tasks (workers) related to channels. This module contains methods for managing tasks (workers) related to channels.
""" """

View file

@ -1,18 +1,18 @@
defmodule Pinchflat.Tasks.ChannelTasksTest do defmodule Pinchflat.Tasks.SourceTasksTest do
use Pinchflat.DataCase use Pinchflat.DataCase
import Pinchflat.TasksFixtures import Pinchflat.TasksFixtures
import Pinchflat.MediaSourceFixtures import Pinchflat.MediaSourceFixtures
alias Pinchflat.Tasks.Task alias Pinchflat.Tasks.Task
alias Pinchflat.Tasks.ChannelTasks alias Pinchflat.Tasks.SourceTasks
alias Pinchflat.Workers.MediaIndexingWorker alias Pinchflat.Workers.MediaIndexingWorker
describe "kickoff_indexing_task/1" do describe "kickoff_indexing_task/1" do
test "it does not schedule a job if the interval is <= 0" do test "it does not schedule a job if the interval is <= 0" do
source = source_fixture(index_frequency_minutes: -1) source = source_fixture(index_frequency_minutes: -1)
assert {:ok, :should_not_index} = ChannelTasks.kickoff_indexing_task(source) assert {:ok, :should_not_index} = SourceTasks.kickoff_indexing_task(source)
refute_enqueued(worker: MediaIndexingWorker, args: %{"id" => source.id}) refute_enqueued(worker: MediaIndexingWorker, args: %{"id" => source.id})
end end
@ -20,7 +20,7 @@ defmodule Pinchflat.Tasks.ChannelTasksTest do
test "it schedules a job if the interval is > 0" do test "it schedules a job if the interval is > 0" do
source = source_fixture(index_frequency_minutes: 1) source = source_fixture(index_frequency_minutes: 1)
assert {:ok, _} = ChannelTasks.kickoff_indexing_task(source) assert {:ok, _} = SourceTasks.kickoff_indexing_task(source)
assert_enqueued(worker: MediaIndexingWorker, args: %{"id" => source.id}) assert_enqueued(worker: MediaIndexingWorker, args: %{"id" => source.id})
end end
@ -28,7 +28,7 @@ defmodule Pinchflat.Tasks.ChannelTasksTest do
test "it creates and attaches a task if the interval is > 0" do test "it creates and attaches a task if the interval is > 0" do
source = source_fixture(index_frequency_minutes: 1) source = source_fixture(index_frequency_minutes: 1)
assert {:ok, %Task{} = task} = ChannelTasks.kickoff_indexing_task(source) assert {:ok, %Task{} = task} = SourceTasks.kickoff_indexing_task(source)
assert task.source_id == source.id assert task.source_id == source.id
end end
@ -37,7 +37,7 @@ defmodule Pinchflat.Tasks.ChannelTasksTest do
source = source_fixture() source = source_fixture()
task = task_fixture(source_id: source.id) task = task_fixture(source_id: source.id)
assert {:ok, _} = ChannelTasks.kickoff_indexing_task(source) assert {:ok, _} = SourceTasks.kickoff_indexing_task(source)
assert_raise Ecto.NoResultsError, fn -> Repo.reload!(task) end assert_raise Ecto.NoResultsError, fn -> Repo.reload!(task) end
end end