Model#search: factor out username search.

This commit is contained in:
evazion
2019-08-19 17:58:23 -05:00
parent 9a3e9747d8
commit c3ad7f6112
26 changed files with 41 additions and 189 deletions

View File

@@ -48,9 +48,7 @@ class ForumPost < ApplicationRecord
q = super
q = q.permitted
if params[:creator_id].present?
q = q.where("forum_posts.creator_id = ?", params[:creator_id].to_i)
end
q = q.search_user_attribute(:creator, params)
if params[:topic_id].present?
q = q.where("forum_posts.topic_id = ?", params[:topic_id].to_i)
@@ -62,10 +60,6 @@ class ForumPost < ApplicationRecord
q = q.attribute_matches(:body, params[:body_matches], index_column: :text_index)
if params[:creator_name].present?
q = q.creator_name(params[:creator_name].tr(" ", "_"))
end
if params[:topic_category_id].present?
q = q.joins(:topic).where("forum_topics.category_id = ?", params[:topic_category_id].to_i)
end