Fix #3696: API: handle boolean params consistently
* Use ApplicationRecord#attribute_matches to handle boolean attributes consistently in search methods. * Add support for searching various boolean attributes that previously weren't supported.
This commit is contained in:
@@ -566,17 +566,8 @@ class Artist < ApplicationRecord
|
||||
q = q.url_matches(params[:url_matches])
|
||||
end
|
||||
|
||||
if params[:is_active] == "true"
|
||||
q = q.active
|
||||
elsif params[:is_active] == "false"
|
||||
q = q.deleted
|
||||
end
|
||||
|
||||
if params[:is_banned] == "true"
|
||||
q = q.banned
|
||||
elsif params[:is_banned] == "false"
|
||||
q = q.unbanned
|
||||
end
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user