mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 07:13:44 +08:00
Merge pull request #2416 from ligthyear/min-max-params
add min_posts, max_posts to filter the topic list queries
This commit is contained in:
commit
222e13e5cc
|
@ -267,6 +267,8 @@ class ListController < ApplicationController
|
||||||
category: params[:category],
|
category: params[:category],
|
||||||
order: params[:order],
|
order: params[:order],
|
||||||
ascending: params[:ascending],
|
ascending: params[:ascending],
|
||||||
|
min_posts: params[:min_posts],
|
||||||
|
max_posts: params[:max_posts],
|
||||||
status: params[:status]
|
status: params[:status]
|
||||||
}
|
}
|
||||||
options[:no_subcategories] = true if params[:no_subcategories] == 'true'
|
options[:no_subcategories] = true if params[:no_subcategories] == 'true'
|
||||||
|
|
|
@ -13,6 +13,8 @@ class TopicQuery
|
||||||
limit
|
limit
|
||||||
page
|
page
|
||||||
per_page
|
per_page
|
||||||
|
min_posts
|
||||||
|
max_posts
|
||||||
topic_ids
|
topic_ids
|
||||||
visible
|
visible
|
||||||
category
|
category
|
||||||
|
@ -266,6 +268,9 @@ class TopicQuery
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result = result.where('topics.posts_count <= ?', options[:max_posts]) if options[:max_posts].present?
|
||||||
|
result = result.where('topics.posts_count >= ?', options[:min_posts]) if options[:min_posts].present?
|
||||||
|
|
||||||
guardian = Guardian.new(@user)
|
guardian = Guardian.new(@user)
|
||||||
if !guardian.is_admin?
|
if !guardian.is_admin?
|
||||||
allowed_ids = guardian.allowed_category_ids
|
allowed_ids = guardian.allowed_category_ids
|
||||||
|
|
Loading…
Reference in New Issue
Block a user