Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include video posts in art feeds #258

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ func ServiceWithDefaultFeeds(pgxStore *store.PGXStore) *Service {
generatorOpts: generatorOpts{
DisallowedHashtags: defaultDisallowedHashtags,
HasVideo: tristate.True,
HasMedia: tristate.False,
IsNSFW: tristate.True,
},
}))
Expand All @@ -579,6 +580,7 @@ func ServiceWithDefaultFeeds(pgxStore *store.PGXStore) *Service {
generatorOpts: generatorOpts{
DisallowedHashtags: defaultDisallowedHashtags,
HasVideo: tristate.True,
HasMedia: tristate.False,
IsNSFW: tristate.True,
},
}))
Expand Down
13 changes: 9 additions & 4 deletions feed/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestGenerator(t *testing.T) {
HasMedia: tristate.True,
},
},
expectedPosts: []string{artPost, nsfwArtPost, nsfwLabelledPost},
expectedPosts: []string{artPost, nsfwArtPost, nsfwLabelledPost, artVideoPost, nsfwArtVideoPost},
},
{
name: "nsfw only art",
Expand All @@ -196,13 +196,14 @@ func TestGenerator(t *testing.T) {
HasMedia: tristate.True,
},
},
expectedPosts: []string{nsfwArtPost, nsfwLabelledPost},
expectedPosts: []string{nsfwArtPost, nsfwLabelledPost, nsfwArtVideoPost},
},
{
name: "pinned post",
opts: chronologicalGeneratorOpts{
generatorOpts: generatorOpts{
Hashtags: []string{"placeholder"},
HasMedia: tristate.False,
},
PinnedDIDs: []string{pinnedFurry.DID()},
},
Expand All @@ -214,6 +215,7 @@ func TestGenerator(t *testing.T) {
generatorOpts: generatorOpts{
Hashtags: []string{},
HasVideo: tristate.True,
HasMedia: tristate.False,
},
},
expectedPosts: []string{videoPost, nsfwVideoPost, artVideoPost, nsfwArtVideoPost},
Expand All @@ -224,6 +226,7 @@ func TestGenerator(t *testing.T) {
generatorOpts: generatorOpts{
IsNSFW: tristate.True,
HasVideo: tristate.True,
HasMedia: tristate.False,
},
},
expectedPosts: []string{nsfwVideoPost, nsfwArtVideoPost},
Expand Down Expand Up @@ -315,7 +318,7 @@ func TestGenerator(t *testing.T) {
HasMedia: tristate.True,
},
},
expectedPosts: []string{artPost, nsfwArtPost, nsfwLabelledPost},
expectedPosts: []string{artPost, nsfwArtPost, nsfwLabelledPost, artVideoPost, nsfwArtVideoPost},
},
{
name: "nsfw only art",
Expand All @@ -327,7 +330,7 @@ func TestGenerator(t *testing.T) {
HasMedia: tristate.True,
},
},
expectedPosts: []string{nsfwArtPost, nsfwLabelledPost},
expectedPosts: []string{nsfwArtPost, nsfwLabelledPost, nsfwArtVideoPost},
},
{
name: "all videos",
Expand All @@ -336,6 +339,7 @@ func TestGenerator(t *testing.T) {
generatorOpts: generatorOpts{
Hashtags: []string{},
HasVideo: tristate.True,
HasMedia: tristate.False,
},
},
expectedPosts: []string{videoPost, nsfwVideoPost, artVideoPost, nsfwArtVideoPost},
Expand All @@ -348,6 +352,7 @@ func TestGenerator(t *testing.T) {
Hashtags: []string{},
IsNSFW: tristate.True,
HasVideo: tristate.True,
HasMedia: tristate.False,
},
},
expectedPosts: []string{nsfwVideoPost, nsfwArtVideoPost},
Expand Down
36 changes: 20 additions & 16 deletions store/gen/candidate_posts.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 20 additions & 16 deletions store/queries/candidate_posts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ WHERE
COALESCE(sqlc.narg(disallowed_hashtags)::TEXT [], '{}') = '{}'
OR NOT sqlc.narg(disallowed_hashtags)::TEXT [] && cp.hashtags
)
-- Match has_media status. If unspecified, do not filter.
AND (
sqlc.narg(has_media)::BOOLEAN IS NULL
OR COALESCE(cp.has_media, FALSE) = sqlc.narg(has_media)
)
-- Match has_video status. If unspecified, do not filter.
AND (
sqlc.narg(has_video)::BOOLEAN IS NULL
OR COALESCE(cp.has_video, FALSE) = sqlc.narg(has_video)
-- Match has_media status. If unspecified, do not filter.
(
sqlc.narg(has_media)::BOOLEAN IS NULL
OR COALESCE(cp.has_media, FALSE) = sqlc.narg(has_media)
)
-- Match has_video status. If unspecified, do not filter.
OR (
sqlc.narg(has_video)::BOOLEAN IS NULL
OR COALESCE(cp.has_video, FALSE) = sqlc.narg(has_video)
)
)
-- Filter by NSFW status. If unspecified, do not filter.
AND (
Expand Down Expand Up @@ -109,15 +111,17 @@ WHERE
COALESCE(sqlc.narg(disallowed_hashtags)::TEXT [], '{}') = '{}'
OR NOT sqlc.narg(disallowed_hashtags)::TEXT [] && cp.hashtags
)
-- Match has_media status. If unspecified, do not filter.
AND (
sqlc.narg(has_media)::BOOLEAN IS NULL
OR COALESCE(cp.has_media, FALSE) = sqlc.narg(has_media)
)
-- Match has_video status. If unspecified, do not filter.
AND (
sqlc.narg(has_video)::BOOLEAN IS NULL
OR COALESCE(cp.has_video, FALSE) = sqlc.narg(has_video)
-- Match has_media status. If unspecified, do not filter.
(
sqlc.narg(has_media)::BOOLEAN IS NULL
OR COALESCE(cp.has_media, FALSE) = sqlc.narg(has_media)
)
-- Match has_video status. If unspecified, do not filter.
OR (
sqlc.narg(has_video)::BOOLEAN IS NULL
OR COALESCE(cp.has_video, FALSE) = sqlc.narg(has_video)
)
)
-- Filter by NSFW status. If unspecified, do not filter.
AND (
Expand Down
Loading