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

@@ -9,15 +9,7 @@ class JanitorTrial < ApplicationRecord
def self.search(params)
q = super.where(status: "active")
if params[:user_name]
q = q.where("user_id = (select _.id from users _ where lower(_.name) = ?)", params[:user_name].mb_chars.downcase)
end
if params[:user_id]
q = q.where("user_id = ?", params[:user_id].to_i)
end
q = q.search_user_attribute(:user, params)
q.apply_default_order(params)
end