add min_posts, max_posts to filter the topic list queries

superseeds #2412
This commit is contained in:
Benjamin Kampmann 2014-06-05 15:30:24 +02:00
parent a4de1f25c1
commit 6b3d5c7348
2 changed files with 7 additions and 0 deletions

View File

@ -267,6 +267,8 @@ class ListController < ApplicationController
category: params[:category],
order: params[:order],
ascending: params[:ascending],
min_posts: params[:min_posts],
max_posts: params[:max_posts],
status: params[:status]
}
options[:no_subcategories] = true if params[:no_subcategories] == 'true'

View File

@ -13,6 +13,8 @@ class TopicQuery
limit
page
per_page
min_posts
max_posts
topic_ids
visible
category
@ -266,6 +268,9 @@ class TopicQuery
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)
if !guardian.is_admin?
allowed_ids = guardian.allowed_category_ids