Model#search: factor out username search.
This commit is contained in:
@@ -511,14 +511,7 @@ class Artist < ApplicationRecord
|
||||
|
||||
q = q.attribute_matches(:is_active, params[:is_active])
|
||||
q = q.attribute_matches(:is_banned, params[:is_banned])
|
||||
|
||||
if params[:creator_name].present?
|
||||
q = q.where("artists.creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].tr(" ", "_").mb_chars.downcase)
|
||||
end
|
||||
|
||||
if params[:creator_id].present?
|
||||
q = q.where("artists.creator_id = ?", params[:creator_id].to_i)
|
||||
end
|
||||
q = q.search_user_attribute(:creator, params)
|
||||
|
||||
if params[:has_tag].to_s.truthy?
|
||||
q = q.joins(:tag).where("tags.post_count > 0")
|
||||
|
||||
Reference in New Issue
Block a user