Source title regex filtering (#98)

* Added a basic/advanced mode to source form

* Added regex field and UI to source form

* Implemented title regex filtering
This commit is contained in:
Kieran
2024-03-20 17:51:14 -07:00
committed by GitHub
parent 1328dff7d6
commit 3c522d8d6b
33 changed files with 95 additions and 11 deletions
+9
View File
@@ -66,6 +66,7 @@ defmodule Pinchflat.Media do
|> where([mi], mi.source_id == ^source.id and is_nil(mi.media_filepath))
|> where(^build_format_clauses(media_profile))
|> where(^maybe_apply_cutoff_date(source))
|> where(^maybe_apply_title_regex(source))
|> Repo.maybe_limit(limit)
|> Repo.all()
end
@@ -247,6 +248,14 @@ defmodule Pinchflat.Media do
end
end
defp maybe_apply_title_regex(source) do
if source.title_filter_regex do
dynamic([mi], fragment("regexp_like(?, ?)", mi.title, ^source.title_filter_regex))
else
dynamic(true)
end
end
defp build_format_clauses(media_profile) do
mapped_struct = Map.from_struct(media_profile)