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:
evazion
2021-10-13 04:10:23 -05:00
parent d771f6f41b
commit c0f744f84d
2 changed files with 11 additions and 0 deletions

View File

@@ -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