Prior to this commit, we had two places that need to know the nuances ofquerying for tag flares and what we should include in our queries for serialization. With this commit, we're factoring towards a common source of knowledge and providing a much needed test for the expected output of this serialization. Loosely related to #15916, #15983, #15994, and #16032.
37 lines
906 B
Ruby
37 lines
906 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: [],
|
|
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,
|
|
sort_by: sort_by,
|
|
sort_direction: sort_direction,
|
|
page: page,
|
|
per_page: per_page,
|
|
)
|
|
|
|
Homepage::ArticleSerializer.serialized_collection_from(relation: articles)
|
|
end
|
|
end
|
|
end
|