docbrown/app/services/homepage/fetch_articles.rb
Joshua Wehner d227e1d285
Suppressing articles negative-follow tags from appearing in the "relevant" feed (#19948)
* Try suppressing all negative-follow tags

* userData isn't always available

* Bolster test coverage for tag filter scenarios

* Antitags for the non-basic 'strategy'

* Rename antitags -> hidden_tags

* Rename 'anti_tags' -> 'hidden_tags' as well

* Use userData.followed_tags to derive hidden_tags
2023-08-28 10:11:20 -04:00

39 lines
963 B
Ruby

# This is used to populate the following pages:
# => homepage
# => profile page
# => organization page
# => tag index page
# TODO: rename `Homepage::FetchArticles` to something more generic
module Homepage
class FetchArticles
DEFAULT_PER_PAGE = 60
def self.call(
approved: nil,
published_at: nil,
user_id: nil,
organization_id: nil,
tags: [],
hidden_tags: [],
sort_by: nil,
sort_direction: nil,
page: 0,
per_page: DEFAULT_PER_PAGE
)
articles = Homepage::ArticlesQuery.call(
approved: approved,
published_at: published_at,
user_id: user_id,
organization_id: organization_id,
tags: tags,
hidden_tags: hidden_tags,
sort_by: sort_by,
sort_direction: sort_direction,
page: page,
per_page: per_page,
)
Homepage::ArticleSerializer.serialized_collection_from(relation: articles)
end
end
end