Normalizing feed page size (#15326)
This commit removes a handful of magic numbers and instead relies on a constant. This has a small impact in that the Basic feed will now return 50 articles instead of 25. However, normalizing the feed pagination window size helps reduce some oddities in reporting. In addition, this might be something we consider giving administrators the ability to set (with default options, because we shouldn't allow page sizes of 10_000 as that's a massive memory hog). Related to #14709
This commit is contained in:
parent
f712b796b2
commit
f5243ea844
6 changed files with 7 additions and 5 deletions
|
|
@ -9,6 +9,8 @@ class Article < ApplicationRecord
|
|||
acts_as_taggable_on :tags
|
||||
resourcify
|
||||
|
||||
DEFAULT_FEED_PAGINATION_WINDOW_SIZE = 50
|
||||
|
||||
attr_accessor :publish_under_org
|
||||
attr_writer :series
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Articles
|
||||
module Feeds
|
||||
class Basic
|
||||
def initialize(user: nil, number_of_articles: 25, page: 1, tag: nil)
|
||||
def initialize(user: nil, number_of_articles: Article::DEFAULT_FEED_PAGINATION_WINDOW_SIZE, page: 1, tag: nil)
|
||||
@user = user
|
||||
@number_of_articles = number_of_articles
|
||||
@page = page
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Articles
|
||||
module Feeds
|
||||
class LargeForemExperimental
|
||||
def initialize(user: nil, number_of_articles: 50, page: 1, tag: nil)
|
||||
def initialize(user: nil, number_of_articles: Article::DEFAULT_FEED_PAGINATION_WINDOW_SIZE, page: 1, tag: nil)
|
||||
@user = user
|
||||
@number_of_articles = number_of_articles
|
||||
@page = page
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module Articles
|
|||
module Latest
|
||||
MINIMUM_SCORE = -20
|
||||
|
||||
def self.call(tag: nil, number_of_articles: 50, page: 1)
|
||||
def self.call(tag: nil, number_of_articles: Article::DEFAULT_FEED_PAGINATION_WINDOW_SIZE, page: 1)
|
||||
Articles::Feeds::Tag.call(tag)
|
||||
.order(published_at: :desc)
|
||||
.where("score > ?", MINIMUM_SCORE)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Articles
|
||||
module Feeds
|
||||
module Tag
|
||||
def self.call(tag = nil, number_of_articles: 50, page: 1)
|
||||
def self.call(tag = nil, number_of_articles: Article::DEFAULT_FEED_PAGINATION_WINDOW_SIZE, page: 1)
|
||||
articles =
|
||||
if tag.present?
|
||||
if FeatureFlag.enabled?(:optimize_article_tag_query)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Articles
|
||||
module Feeds
|
||||
module Timeframe
|
||||
def self.call(timeframe, tag: nil, number_of_articles: 50, page: 1)
|
||||
def self.call(timeframe, tag: nil, number_of_articles: Article::DEFAULT_FEED_PAGINATION_WINDOW_SIZE, page: 1)
|
||||
articles = ::Articles::Feeds::Tag.call(tag)
|
||||
|
||||
articles
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue