Model#search: refactor searching for attributes.

This commit is contained in:
evazion
2019-08-29 20:24:52 -05:00
parent 6fc4b63fa8
commit 7b8584e3b0
26 changed files with 90 additions and 212 deletions

View File

@@ -51,7 +51,8 @@ class PostFlag < ApplicationRecord
def search(params)
q = super
q = q.attribute_matches(:reason, params[:reason_matches])
q = q.search_attributes(params, :post, :is_resolved)
q = q.text_attribute_matches(:reason, params[:reason_matches])
# XXX
if params[:creator_id].present?
@@ -74,9 +75,6 @@ class PostFlag < ApplicationRecord
end
end
q = q.search_post_id_attribute(params)
q = q.attribute_matches(:is_resolved, params[:is_resolved])
case params[:category]
when "normal"
q = q.where("reason NOT IN (?) AND reason NOT LIKE ?", [Reasons::UNAPPROVED, Reasons::BANNED], Reasons::REJECTED)