modqueue: add order options; change default order to newest first.

* Add options for changing the order of the modqueue (newest first,
  oldest first, highest scoring first, lowest scoring first).

* Change the default order from oldest posts first to most recently
  flagged or uploaded posts first.

* Add an order:modqueue metatag to order by most recently flagged or
  uploaded in standard searches.
This commit is contained in:
evazion
2020-03-03 00:52:18 -06:00
parent 9ddf408ec5
commit 04b69954eb
6 changed files with 51 additions and 13 deletions

View File

@@ -493,7 +493,17 @@ class PostQueryBuilder
relation = relation.where("posts.image_width IS NOT NULL and posts.image_height IS NOT NULL")
end
case q[:order]
if q[:order] == "custom" && q[:post_id].present? && q[:post_id][0] == :in
relation = relation.find_ordered(q[:post_id][1])
else
relation = PostQueryBuilder.search_order(relation, q[:order])
end
relation
end
def self.search_order(relation, order)
case order.to_s
when "id", "id_asc"
relation = relation.order("posts.id ASC")
@@ -602,10 +612,11 @@ class PostQueryBuilder
.select("posts.*, COUNT(*) AS contributor_fav_count")
.order("contributor_fav_count DESC, posts.fav_count DESC, posts.id DESC")
when "custom"
if q[:post_id].present? && q[:post_id][0] == :in
relation = relation.find_ordered(q[:post_id][1])
end
when "modqueue", "modqueue_desc"
relation = relation.left_outer_joins(:flags).order("GREATEST(posts.created_at, post_flags.created_at) DESC, posts.id DESC")
when "modqueue_asc"
relation = relation.left_outer_joins(:flags).order("GREATEST(posts.created_at, post_flags.created_at) ASC, posts.id ASC")
else
relation = relation.order("posts.id DESC")