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

@@ -515,6 +515,11 @@ class PostQueryBuilder
when "rank"
relation = relation.order("log(3, posts.score) + (extract(epoch from posts.created_at) - extract(epoch from timestamp '2005-05-24')) / 35000 DESC")
when "custom"
if q[:post_id].present? && q[:post_id][0] == :in
relation = relation.find_ordered(q[:post_id][1])
end
else
relation = relation.order("posts.id DESC")
end