Move all order logic to models
- Have a default order for each model -- The overall default is ID DESC - Allow for custom orderings -- When comma-separated IDs are used
This commit is contained in:
@@ -27,7 +27,6 @@ class Ban < ApplicationRecord
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:banner_name]
|
||||
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].mb_chars.downcase)
|
||||
@@ -58,7 +57,7 @@ class Ban < ApplicationRecord
|
||||
when "expires_at_desc"
|
||||
q = q.order("bans.expires_at desc")
|
||||
else
|
||||
q = q.order("bans.id desc")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
Reference in New Issue
Block a user