Updated fast indexing to respect title filters (#136)
This commit is contained in:
parent
23d65eaf5f
commit
d1fe87bdf3
2 changed files with 22 additions and 0 deletions
|
|
@ -101,6 +101,7 @@ defmodule Pinchflat.Media do
|
|||
|> where([mi], mi.id == ^media_item.id and is_nil(mi.media_filepath))
|
||||
|> where(^build_format_clauses(media_item.source.media_profile))
|
||||
|> where(^maybe_apply_cutoff_date(media_item.source))
|
||||
|> where(^maybe_apply_title_regex(media_item.source))
|
||||
|> Repo.exists?()
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -325,6 +325,27 @@ defmodule Pinchflat.MediaTest do
|
|||
|
||||
assert Media.pending_download?(media_item)
|
||||
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
|
||||
|
||||
describe "search/1" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue