Fix #3430: Accept the search[id] param in all controllers.

* Allow every controller to take the `search[id]` param.

* Parse the `search[id]` param the same way that the `id:<N>` metatag is
  parsed. So `search[id]=1,2,3`, `search[id]=<42`, `search[id]=1..10`, for
  example, are all accepted.
This commit is contained in:
evazion
2017-12-17 16:58:34 -06:00
parent 49577e3fac
commit 0ca726802f
28 changed files with 72 additions and 58 deletions

View File

@@ -426,7 +426,7 @@ class Artist < ApplicationRecord
end
def search(params)
q = where("true")
q = super
params = {} if params.blank?
case params[:name]
@@ -496,10 +496,6 @@ class Artist < ApplicationRecord
q = q.unbanned
end
if params[:id].present?
q = q.where("artists.id in (?)", params[:id].split(",").map(&:to_i))
end
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