search: add order:md5, order:none metatags.

These may be useful for fast pseudo-random shufflings of search results.
This commit is contained in:
evazion
2020-04-27 23:21:08 -05:00
parent fad217fc2d
commit 4b38092b39
2 changed files with 18 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ class PostQueryBuilder
ORDER_METATAGS = %w[
id id_desc
md5 md5_asc
score score_asc
favcount favcount_asc
created_at created_at_asc
@@ -81,6 +82,7 @@ class PostQueryBuilder
modqueue
random
custom
none
] +
COUNT_METATAGS +
COUNT_METATAG_SYNONYMS.flat_map { |str| [str, "#{str}_asc"] } +
@@ -561,6 +563,12 @@ class PostQueryBuilder
when "id_desc"
relation = relation.order("posts.id DESC")
when "md5", "md5_desc"
relation = relation.order("posts.md5 DESC")
when "md5_asc"
relation = relation.order("posts.md5 ASC")
when "score", "score_desc"
relation = relation.order("posts.score DESC, posts.id DESC")
@@ -672,6 +680,9 @@ class PostQueryBuilder
when "modqueue_asc"
relation = relation.left_outer_joins(:flags).order(Arel.sql("GREATEST(posts.created_at, post_flags.created_at) ASC, posts.id ASC"))
when "none"
relation = relation.reorder(nil)
else
relation = relation.order("posts.id DESC")
end