Change Channel to Source (#12)

* Ensure channel detail lookup doesn't download the video - oops

* Ran the needful migrations for replacing channels with sources

* got media source test back working

* channel tasks test

* Media indexing worker test

* media tests

* Got all tests working except controller tests

* got all tests working

* Renamed Channel struct to Source

* renamed ChannelTasks

* More renaming; renamed channel details module

* Removed Channel yt-dlp module, instead throwing things in the VideoCollection module

* Renamed what looks like the last of the outstanding data
This commit is contained in:
Kieran
2024-02-02 17:45:21 -08:00
committed by GitHub
parent 977b69b7c3
commit 366fd80213
46 changed files with 805 additions and 762 deletions
@@ -1,28 +1,28 @@
defmodule Pinchflat.Tasks.ChannelTasks do
defmodule Pinchflat.Tasks.SourceTasks do
@moduledoc """
This module contains methods for managing tasks (workers) related to channels.
This module contains methods for managing tasks (workers) related to sources.
"""
alias Pinchflat.Tasks
alias Pinchflat.MediaSource.Channel
alias Pinchflat.MediaSource.Source
alias Pinchflat.Workers.MediaIndexingWorker
@doc """
Starts tasks for indexing a channel's media.
Starts tasks for indexing a source's media.
Returns {:ok, :should_not_index} | {:ok, %Task{}}.
"""
def kickoff_indexing_task(%Channel{} = channel) do
Tasks.delete_pending_tasks_for(channel)
def kickoff_indexing_task(%Source{} = source) do
Tasks.delete_pending_tasks_for(source)
if channel.index_frequency_minutes <= 0 do
if source.index_frequency_minutes <= 0 do
{:ok, :should_not_index}
else
channel
source
|> Map.take([:id])
# Schedule this one immediately, but future ones will be on an interval
|> MediaIndexingWorker.new()
|> Tasks.create_job_with_task(channel)
|> Tasks.create_job_with_task(source)
|> case do
# This should never return {:error, :duplicate_job} since we just deleted
# any pending tasks. I'm being assertive about it so it's obvious if I'm wrong
+3 -3
View File
@@ -7,11 +7,11 @@ defmodule Pinchflat.Tasks.Task do
import Ecto.Changeset
alias Pinchflat.Media.MediaItem
alias Pinchflat.MediaSource.Channel
alias Pinchflat.MediaSource.Source
schema "tasks" do
belongs_to :job, Oban.Job
belongs_to :channel, Channel
belongs_to :source, Source
belongs_to :media_item, MediaItem
timestamps(type: :utc_datetime)
@@ -20,7 +20,7 @@ defmodule Pinchflat.Tasks.Task do
@doc false
def changeset(task, attrs) do
task
|> cast(attrs, [:job_id, :channel_id, :media_item_id])
|> cast(attrs, [:job_id, :source_id, :media_item_id])
|> validate_required([:job_id])
end
end