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

@@ -30,21 +30,8 @@ class BulkUpdateRequest < ApplicationRecord
def search(params = {})
q = super
if params[:user_name].present?
q = q.where(user_id: User.name_to_id(params[:user_name]))
end
if params[:user_id].present?
q = q.where(user_id: params[:user_id].split(",").map(&:to_i))
end
if params[:approver_name].present?
q = q.where(approver_id: User.name_to_id(params[:approver_name]))
end
if params[:approver_id].present?
q = q.where(approver_id: params[:approver_id].split(",").map(&:to_i))
end
q = q.search_user_attribute(:user, params)
q = q.search_user_attribute(:approver, params)
if params[:forum_topic_id].present?
q = q.where(forum_topic_id: params[:forum_topic_id].split(",").map(&:to_i))