Fix #4893: Add a FIELD_present parameter variation for text fields.
Usage: * https://danbooru.donmai.us/wiki_pages.json?search[body_present]=true * https://danbooru.donmai.us/wiki_pages.json?search[body_present]=false
This commit is contained in:
@@ -307,6 +307,14 @@ module Searchable
|
||||
relation = relation.where(attr => params[attr])
|
||||
end
|
||||
|
||||
if params[:"#{attr}_present"].present? && params[:"#{attr}_present"].truthy?
|
||||
relation = relation.where.not(attr => "")
|
||||
end
|
||||
|
||||
if params[:"#{attr}_present"].present? && params[:"#{attr}_present"].falsy?
|
||||
relation = relation.where(attr => "")
|
||||
end
|
||||
|
||||
if params[:"#{attr}_eq"].present?
|
||||
relation = relation.where(attr => params[:"#{attr}_eq"])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user