mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: do not redirect to top page when number of topis is low
This commit is contained in:
@@ -9,7 +9,8 @@ class SiteSerializer < ApplicationSerializer
|
||||
:top_menu_items,
|
||||
:anonymous_top_menu_items,
|
||||
:uncategorized_category_id, # this is hidden so putting it here
|
||||
:is_readonly
|
||||
:is_readonly,
|
||||
:has_enough_topic_to_redirect_to_top_page
|
||||
|
||||
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
|
||||
has_many :post_action_types, embed: :objects
|
||||
@@ -50,4 +51,12 @@ class SiteSerializer < ApplicationSerializer
|
||||
Discourse.readonly_mode?
|
||||
end
|
||||
|
||||
def has_enough_topic_to_redirect_to_top_page
|
||||
Topic.listable_topics
|
||||
.visible
|
||||
.includes(:category).references(:category)
|
||||
.where('COALESCE(categories.topic_id, 0) <> topics.id')
|
||||
.count > SiteSetting.topics_per_period_in_top_page
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user