diff --git a/lib/pinchflat/boot/data_backfill_worker.ex b/lib/pinchflat/boot/data_backfill_worker.ex index c7a1a7b2..37cd9465 100644 --- a/lib/pinchflat/boot/data_backfill_worker.ex +++ b/lib/pinchflat/boot/data_backfill_worker.ex @@ -18,7 +18,6 @@ defmodule Pinchflat.Boot.DataBackfillWorker do alias __MODULE__ alias Pinchflat.Repo - alias Pinchflat.Media.MediaItem @doc """ Cancels all pending backfill jobs. Useful for ensuring worker runs immediately @@ -44,26 +43,14 @@ defmodule Pinchflat.Boot.DataBackfillWorker do """ def perform(%Oban.Job{}) do Logger.info("Running data backfill worker") - backfill_shorts_data() + # Nothing to do for now - just reschedule + # Keeping in-place because we _will_ need it in the future reschedule_backfill() :ok end - defp backfill_shorts_data do - query = - from( - m in MediaItem, - where: fragment("? like ?", m.original_url, "%/shorts/%"), - where: m.short_form_content == false - ) - - {count, _} = Repo.update_all(query, set: [short_form_content: true]) - - Logger.info("Backfill worker set short_form_content to true for #{count} media items.") - end - defp reschedule_backfill do # Run hourly next_run_in = 60 * 60 diff --git a/lib/pinchflat/boot/pre_job_startup_tasks.ex b/lib/pinchflat/boot/pre_job_startup_tasks.ex index 087f2b97..0e28d940 100644 --- a/lib/pinchflat/boot/pre_job_startup_tasks.ex +++ b/lib/pinchflat/boot/pre_job_startup_tasks.ex @@ -34,7 +34,6 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do reset_executing_jobs() create_blank_cookie_file() apply_default_settings() - rename_old_job_workers() {:ok, state} end @@ -55,9 +54,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do base_dir = Application.get_env(:pinchflat, :extras_directory) filepath = Path.join(base_dir, "cookies.txt") - if File.exists?(filepath) do - Logger.info("Cookies file exists") - else + if !File.exists?(filepath) do Logger.info("Cookies does not exist - creating it") FilesystemHelpers.write_p!(filepath, "") @@ -68,33 +65,4 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do Settings.fetch!(:onboarding, true) Settings.fetch!(:pro_enabled, false) end - - # As part of a large refactor, I ended up moving a bunch of workers around. This - # is a problem because the workers are stored in the database and the runner - # will try to run the OLD jobs. This is also why these tasks run before the job - # runner starts up. - # - # Can be removed after a few months (created: 2024-03-12) - defp rename_old_job_workers do - # [ [old_name, new_name], ...] - rename_map = [ - ["Pinchflat.Workers.MediaIndexingWorker", "Pinchflat.FastIndexing.MediaIndexingWorker"], - ["Pinchflat.Workers.MediaDownloadWorker", "Pinchflat.Downloading.MediaDownloadWorker"], - ["Pinchflat.Workers.FastIndexingWorker", "Pinchflat.FastIndexing.FastIndexingWorker"], - ["Pinchflat.Workers.MediaCollectionIndexingWorker", "Pinchflat.SlowIndexing.MediaCollectionIndexingWorker"], - ["Pinchflat.Workers.DataBackfillWorker", "Pinchflat.Boot.DataBackfillWorker"] - ] - - jobs_renamed = - Enum.reduce(rename_map, 0, fn [old_name, new_name], acc -> - {count, _} = - Oban.Job - |> where(worker: ^old_name) - |> Repo.update_all(set: [worker: new_name]) - - acc + count - end) - - Logger.info("Renamed #{jobs_renamed} old job workers") - end end diff --git a/test/pinchflat/boot/data_backfill_worker_test.exs b/test/pinchflat/boot/data_backfill_worker_test.exs index 773cf998..485f2814 100644 --- a/test/pinchflat/boot/data_backfill_worker_test.exs +++ b/test/pinchflat/boot/data_backfill_worker_test.exs @@ -1,8 +1,6 @@ defmodule Pinchflat.Boot.DataBackfillWorkerTest do use Pinchflat.DataCase - import Pinchflat.MediaFixtures - alias Pinchflat.Boot.DataBackfillWorker alias Pinchflat.JobFixtures.TestJobWorker @@ -45,26 +43,4 @@ defmodule Pinchflat.Boot.DataBackfillWorkerTest do assert_enqueued(worker: DataBackfillWorker, scheduled_at: now_plus(60, :minutes)) end end - - describe "perform/1 when testing backfill_shorts_data" do - test "sets short_form_content to true for media items with shorts in the URL" do - media_item = media_item_with_attachments(%{original_url: "https://example.com/shorts/123"}) - - refute media_item.short_form_content - - perform_job(DataBackfillWorker, %{}) - - assert Repo.reload!(media_item).short_form_content - end - - test "does not set short_form_content to true for media items without shorts in the URL" do - media_item = media_item_with_attachments(%{original_url: "https://example.com/longs/123"}) - - refute media_item.short_form_content - - perform_job(DataBackfillWorker, %{}) - - refute Repo.reload!(media_item).short_form_content - end - end end