[Enhancement] Allow forcing a refresh of source metadata (#194)
* Stopped sources from fetching metadata on every update * Added action button to force a metadata refresh
This commit is contained in:
@@ -514,14 +514,24 @@ defmodule Pinchflat.SourcesTest do
|
||||
assert source.index_frequency_minutes == 0
|
||||
end
|
||||
|
||||
test "updating will kickoff a metadata storage worker" do
|
||||
test "updating will kickoff a metadata storage worker if the original_url changes" do
|
||||
expect(YtDlpRunnerMock, :run, &playlist_mock/3)
|
||||
source = source_fixture()
|
||||
update_attrs = %{name: "some updated name"}
|
||||
update_attrs = %{original_url: "https://www.youtube.com/channel/cba321"}
|
||||
|
||||
assert {:ok, %Source{} = source} = Sources.update_source(source, update_attrs)
|
||||
|
||||
assert_enqueued(worker: SourceMetadataStorageWorker, args: %{"id" => source.id})
|
||||
end
|
||||
|
||||
test "updating will not kickoff a metadata storage worker other attrs change" do
|
||||
source = source_fixture()
|
||||
update_attrs = %{name: "some new name"}
|
||||
|
||||
assert {:ok, %Source{}} = Sources.update_source(source, update_attrs)
|
||||
|
||||
refute_enqueued(worker: SourceMetadataStorageWorker)
|
||||
end
|
||||
end
|
||||
|
||||
describe "update_source/3 when testing options" do
|
||||
|
||||
@@ -9,6 +9,7 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||
alias Pinchflat.Repo
|
||||
alias Pinchflat.Settings
|
||||
alias Pinchflat.Downloading.MediaDownloadWorker
|
||||
alias Pinchflat.Metadata.SourceMetadataStorageWorker
|
||||
alias Pinchflat.SlowIndexing.MediaCollectionIndexingWorker
|
||||
|
||||
setup do
|
||||
@@ -215,6 +216,23 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "force_metadata_refresh" do
|
||||
test "forces a metadata refresh", %{conn: conn} do
|
||||
source = source_fixture()
|
||||
|
||||
assert [] = all_enqueued(worker: SourceMetadataStorageWorker)
|
||||
post(conn, ~p"/sources/#{source.id}/force_metadata_refresh")
|
||||
assert [_] = all_enqueued(worker: SourceMetadataStorageWorker)
|
||||
end
|
||||
|
||||
test "redirects to the source page", %{conn: conn} do
|
||||
source = source_fixture()
|
||||
|
||||
conn = post(conn, ~p"/sources/#{source.id}/force_metadata_refresh")
|
||||
assert redirected_to(conn) == ~p"/sources/#{source.id}"
|
||||
end
|
||||
end
|
||||
|
||||
defp create_source(_) do
|
||||
source = source_fixture()
|
||||
media_item = media_item_with_attachments(%{source_id: source.id})
|
||||
|
||||
Reference in New Issue
Block a user