mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
add top page
This commit is contained in:
@@ -8,7 +8,7 @@ require_dependency 'topic_query_sql'
|
||||
|
||||
class TopicQuery
|
||||
# Could be rewritten to %i if Ruby 1.9 is no longer supported
|
||||
VALID_OPTIONS = %w(except_topic_id
|
||||
VALID_OPTIONS = %w(except_topic_ids
|
||||
exclude_category
|
||||
limit
|
||||
page
|
||||
@@ -84,6 +84,12 @@ class TopicQuery
|
||||
create_list(:posted) {|l| l.where('tu.user_id IS NOT NULL') }
|
||||
end
|
||||
|
||||
def list_top(sort_order, period)
|
||||
create_list(:top, unordered: true) do |topics|
|
||||
topics.joins(:top_topic).order("top_topics.#{period}_#{sort_order}_count DESC, topics.bumped_at DESC")
|
||||
end
|
||||
end
|
||||
|
||||
def list_topics_by(user)
|
||||
create_list(:user_topics) do |topics|
|
||||
topics.where(user_id: user.id)
|
||||
@@ -227,7 +233,7 @@ class TopicQuery
|
||||
|
||||
result = result.limit(options[:per_page]) unless options[:limit] == false
|
||||
result = result.visible if options[:visible] || @user.nil? || @user.regular?
|
||||
result = result.where('topics.id <> ?', options[:except_topic_id]).references(:topics) if options[:except_topic_id]
|
||||
result = result.where.not(topics: {id: options[:except_topic_ids]}).references(:topics) if options[:except_topic_ids]
|
||||
result = result.offset(options[:page].to_i * options[:per_page]) if options[:page]
|
||||
|
||||
if options[:topic_ids]
|
||||
|
||||
Reference in New Issue
Block a user