Class: Thredded::PostSqlBuilder

Inherits:
TableSqlBuilder show all
Defined in:
lib/thredded/post_sql_builder.rb

Instance Method Summary collapse

Methods inherited from TableSqlBuilder

#initialize, #sql

Constructor Details

This class inherits a constructor from Thredded::TableSqlBuilder

Instance Method Details

#apply_filters ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/thredded/post_sql_builder.rb', line 3

def apply_filters
  @scope = @scope.joins(:topic_categories).where(category_id: categories) if categories.present?
  return unless users.present? || text.present?
  posts_scope = Thredded::Post
  posts_scope = posts_scope.where(user_id: users) if users.present?
  posts_scope = DbTextSearch::FullTextSearch.new(posts_scope, :content).find(text) if text.present?
  @scope      = @scope.joins(:posts).merge(posts_scope)
end