Model#search: factor out post_tags_match.

This commit is contained in:
evazion
2019-08-29 16:44:19 -05:00
parent c3ad7f6112
commit 6fc4b63fa8
9 changed files with 27 additions and 104 deletions

View File

@@ -20,10 +20,6 @@ class PostReplacement < ApplicationRecord
concerning :Search do
class_methods do
def post_tags_match(query)
where(post_id: PostQueryBuilder.new(query).build.reorder(""))
end
def search(params = {})
q = super
@@ -34,15 +30,7 @@ class PostReplacement < ApplicationRecord
q = q.attribute_matches(:md5_was, params[:md5_was])
q = q.attribute_matches(:md5, params[:md5])
q = q.search_user_attribute(:creator, params)
if params[:post_id].present?
q = q.where(post_id: params[:post_id].split(",").map(&:to_i))
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
q = q.search_post_id_attribute(params)
q.apply_default_order(params)
end
end