Updated search to use new shorts attribute
This commit is contained in:
parent
451c52ae06
commit
a728b4a029
2 changed files with 11 additions and 14 deletions
|
|
@ -257,7 +257,7 @@ defmodule Pinchflat.Media do
|
||||||
{{:shorts_behaviour, :only}, %{livestream_behaviour: :only}} ->
|
{{:shorts_behaviour, :only}, %{livestream_behaviour: :only}} ->
|
||||||
dynamic(
|
dynamic(
|
||||||
[mi],
|
[mi],
|
||||||
^dynamic and (mi.livestream == true or fragment("LOWER(?) LIKE LOWER(?)", mi.original_url, "%/shorts/%"))
|
^dynamic and (mi.livestream == true or mi.short_form_content == true)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Technically redundant, but makes the other clauses easier to parse
|
# Technically redundant, but makes the other clauses easier to parse
|
||||||
|
|
@ -266,16 +266,13 @@ defmodule Pinchflat.Media do
|
||||||
dynamic
|
dynamic
|
||||||
|
|
||||||
{{:shorts_behaviour, :only}, _} ->
|
{{:shorts_behaviour, :only}, _} ->
|
||||||
# return records with /shorts/ in the original_url
|
dynamic([mi], ^dynamic and mi.short_form_content == true)
|
||||||
dynamic([mi], ^dynamic and fragment("LOWER(?) LIKE LOWER(?)", mi.original_url, "%/shorts/%"))
|
|
||||||
|
|
||||||
{{:livestream_behaviour, :only}, _} ->
|
{{:livestream_behaviour, :only}, _} ->
|
||||||
# return records with livestream: true
|
|
||||||
dynamic([mi], ^dynamic and mi.livestream == true)
|
dynamic([mi], ^dynamic and mi.livestream == true)
|
||||||
|
|
||||||
{{:shorts_behaviour, :exclude}, %{livestream_behaviour: lb}} when lb != :only ->
|
{{:shorts_behaviour, :exclude}, %{livestream_behaviour: lb}} when lb != :only ->
|
||||||
# return records without /shorts/ in the original_url
|
dynamic([mi], ^dynamic and mi.short_form_content == false)
|
||||||
dynamic([mi], ^dynamic and fragment("LOWER(?) NOT LIKE LOWER(?)", mi.original_url, "%/shorts/%"))
|
|
||||||
|
|
||||||
{{:livestream_behaviour, :exclude}, %{shorts_behaviour: sb}} when sb != :only ->
|
{{:livestream_behaviour, :exclude}, %{shorts_behaviour: sb}} when sb != :only ->
|
||||||
# return records with livestream: false
|
# return records with livestream: false
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
test "returns shorts and normal media when shorts_behaviour is :include" do
|
test "returns shorts and normal media when shorts_behaviour is :include" do
|
||||||
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :include}).id})
|
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :include}).id})
|
||||||
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [normal, short]
|
assert Media.list_pending_media_items_for(source) == [normal, short]
|
||||||
end
|
end
|
||||||
|
|
@ -105,7 +105,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
test "returns only shorts when shorts_behaviour is :only" do
|
test "returns only shorts when shorts_behaviour is :only" do
|
||||||
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :only}).id})
|
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :only}).id})
|
||||||
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [short]
|
assert Media.list_pending_media_items_for(source) == [short]
|
||||||
end
|
end
|
||||||
|
|
@ -113,7 +113,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
test "returns only normal media when shorts_behaviour is :exclude" do
|
test "returns only normal media when shorts_behaviour is :exclude" do
|
||||||
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :exclude}).id})
|
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :exclude}).id})
|
||||||
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
_short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
_short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [normal]
|
assert Media.list_pending_media_items_for(source) == [normal]
|
||||||
end
|
end
|
||||||
|
|
@ -158,7 +158,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
|
|
||||||
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
||||||
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [normal, livestream, short]
|
assert Media.list_pending_media_items_for(source) == [normal, livestream, short]
|
||||||
end
|
end
|
||||||
|
|
@ -175,7 +175,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
|
|
||||||
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
||||||
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [livestream, short]
|
assert Media.list_pending_media_items_for(source) == [livestream, short]
|
||||||
end
|
end
|
||||||
|
|
@ -192,7 +192,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
|
|
||||||
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
_livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
_livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
||||||
_short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
_short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [normal]
|
assert Media.list_pending_media_items_for(source) == [normal]
|
||||||
end
|
end
|
||||||
|
|
@ -209,7 +209,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
|
|
||||||
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
_normal = media_item_fixture(%{source_id: source.id, media_filepath: nil})
|
||||||
_livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
_livestream = media_item_fixture(%{source_id: source.id, media_filepath: nil, livestream: true})
|
||||||
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
short = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
assert Media.list_pending_media_items_for(source) == [short]
|
assert Media.list_pending_media_items_for(source) == [short]
|
||||||
end
|
end
|
||||||
|
|
@ -249,7 +249,7 @@ defmodule Pinchflat.MediaTest do
|
||||||
|
|
||||||
test "returns false if the media hasn't been downloaded but the profile doesn't DL shorts" do
|
test "returns false if the media hasn't been downloaded but the profile doesn't DL shorts" do
|
||||||
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :exclude}).id})
|
source = source_fixture(%{media_profile_id: media_profile_fixture(%{shorts_behaviour: :exclude}).id})
|
||||||
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, original_url: "/shorts/"})
|
media_item = media_item_fixture(%{source_id: source.id, media_filepath: nil, short_form_content: true})
|
||||||
|
|
||||||
refute Media.pending_download?(media_item)
|
refute Media.pending_download?(media_item)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue