FEATURE: do not redirect to top page when number of topis is low

This commit is contained in:
Régis Hanol
2014-02-17 14:28:12 +01:00
parent 90d20c4373
commit aac4b55926
3 changed files with 34 additions and 7 deletions

View File

@@ -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