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:
@@ -70,23 +70,14 @@ class Pool < ApplicationRecord
|
||||
q = q.where(creator_id: params[:creator_id].split(",").map(&:to_i))
|
||||
end
|
||||
|
||||
if params[:is_active] == "true"
|
||||
q = q.where("pools.is_active = true")
|
||||
elsif params[:is_active] == "false"
|
||||
q = q.where("pools.is_active = false")
|
||||
end
|
||||
|
||||
if params[:category] == "series"
|
||||
q = q.series
|
||||
elsif params[:category] == "collection"
|
||||
q = q.collection
|
||||
end
|
||||
|
||||
if params[:is_deleted] == "true"
|
||||
q = q.deleted
|
||||
else
|
||||
q = q.undeleted
|
||||
end
|
||||
q = q.attribute_matches(:is_active, params[:is_active])
|
||||
q = q.attribute_matches(:is_deleted, params[:is_deleted])
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
|
||||
Reference in New Issue
Block a user