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:
BrokenEagle
2018-01-28 20:46:18 -08:00
parent f83480cc8a
commit d829ab3a00
49 changed files with 134 additions and 116 deletions

View File

@@ -815,7 +815,6 @@ class User < ApplicationRecord
def search(params)
q = super
return q if params.blank?
if params[:name].present?
q = q.name_matches(params[:name].mb_chars.downcase.strip.tr(" ", "_"))
@@ -873,18 +872,14 @@ class User < ApplicationRecord
case params[:order]
when "name"
q = q.order("name")
when "post_upload_count"
q = q.order("post_upload_count desc")
when "note_count"
q = q.order("note_update_count desc")
when "post_update_count"
q = q.order("post_update_count desc")
else
q = q.order("created_at desc")
q = q.apply_default_order(params)
end
q