Updated fast indexing to respect title filters (#136)
This commit is contained in:
@@ -101,6 +101,7 @@ defmodule Pinchflat.Media do
|
|||||||
|> where([mi], mi.id == ^media_item.id and is_nil(mi.media_filepath))
|
|> where([mi], mi.id == ^media_item.id and is_nil(mi.media_filepath))
|
||||||
|> where(^build_format_clauses(media_item.source.media_profile))
|
|> where(^build_format_clauses(media_item.source.media_profile))
|
||||||
|> where(^maybe_apply_cutoff_date(media_item.source))
|
|> where(^maybe_apply_cutoff_date(media_item.source))
|
||||||
|
|> where(^maybe_apply_title_regex(media_item.source))
|
||||||
|> Repo.exists?()
|
|> Repo.exists?()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -325,6 +325,27 @@ defmodule Pinchflat.MediaTest do
|
|||||||
|
|
||||||
assert Media.pending_download?(media_item)
|
assert Media.pending_download?(media_item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns true if the content matches the title regex" do
|
||||||
|
source = source_fixture(%{title_filter_regex: "(?i)^FOO$"})
|
||||||
|
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, title: "foo"})
|
||||||
|
|
||||||
|
assert Media.pending_download?(media_item)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "returns false if the content doesn't match the title regex" do
|
||||||
|
source = source_fixture(%{title_filter_regex: "(?i)^FOO$"})
|
||||||
|
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, title: "bar"})
|
||||||
|
|
||||||
|
refute Media.pending_download?(media_item)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "return true if there is no title regex" do
|
||||||
|
source = source_fixture(%{title_filter_regex: nil})
|
||||||
|
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, title: "foo"})
|
||||||
|
|
||||||
|
assert Media.pending_download?(media_item)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "search/1" do
|
describe "search/1" do
|
||||||
|
|||||||
Reference in New Issue
Block a user