Add order:{tagcount,gentags,arttags,chartags,copytags} metatags.
This commit is contained in:
@@ -307,6 +307,7 @@
|
||||
"id", "id_desc",
|
||||
"score", "score_asc",
|
||||
"favcount", "favcount_asc",
|
||||
"created_at", "created_at_asc",
|
||||
"change", "change_asc",
|
||||
"comment", "comment_asc",
|
||||
"comment_bumped", "comment_bumped_asc",
|
||||
@@ -315,6 +316,11 @@
|
||||
"mpixels", "mpixels_asc",
|
||||
"portrait", "landscape",
|
||||
"filesize", "filesize_asc",
|
||||
"tagcount", "tagcount_asc",
|
||||
"gentags", "gentags_asc",
|
||||
"arttags", "arttags_asc",
|
||||
"chartags", "chartags_asc",
|
||||
"copytags", "copytags_asc",
|
||||
"rank",
|
||||
"random"
|
||||
],
|
||||
|
||||
@@ -497,6 +497,36 @@ class PostQueryBuilder
|
||||
when "filesize_asc"
|
||||
relation = relation.order("posts.file_size ASC")
|
||||
|
||||
when "tagcount", "tagcount_desc"
|
||||
relation = relation.order("posts.tag_count DESC")
|
||||
|
||||
when "tagcount_asc"
|
||||
relation = relation.order("posts.tag_count ASC")
|
||||
|
||||
when "gentags", "gentags_desc"
|
||||
relation = relation.order("posts.tag_count_general DESC")
|
||||
|
||||
when "gentags_asc"
|
||||
relation = relation.order("posts.tag_count_general ASC")
|
||||
|
||||
when "arttags", "arttags_desc"
|
||||
relation = relation.order("posts.tag_count_artist DESC")
|
||||
|
||||
when "arttags_asc"
|
||||
relation = relation.order("posts.tag_count_artist ASC")
|
||||
|
||||
when "chartags", "chartags_desc"
|
||||
relation = relation.order("posts.tag_count_character DESC")
|
||||
|
||||
when "chartags_asc"
|
||||
relation = relation.order("posts.tag_count_character ASC")
|
||||
|
||||
when "copytags", "copytags_desc"
|
||||
relation = relation.order("posts.tag_count_copyright DESC")
|
||||
|
||||
when "copytags_asc"
|
||||
relation = relation.order("posts.tag_count_copyright ASC")
|
||||
|
||||
when "rank"
|
||||
relation = relation.order("log(3, posts.score) + (extract(epoch from posts.created_at) - extract(epoch from timestamp '2005-05-24')) / 35000 DESC")
|
||||
|
||||
|
||||
@@ -2085,6 +2085,8 @@ class PostTest < ActiveSupport::TestCase
|
||||
|
||||
should "return posts ordered by a particular attribute" do
|
||||
posts = (1..2).map do |n|
|
||||
tags = ["tagme", "gentag1 gentag2 artist:arttag char:chartag copy:copytag"]
|
||||
|
||||
p = FactoryGirl.create(
|
||||
:post,
|
||||
score: n,
|
||||
@@ -2093,6 +2095,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
# posts[0] is portrait, posts[1] is landscape. posts[1].mpixels > posts[0].mpixels.
|
||||
image_height: 100*n*n,
|
||||
image_width: 100*(3-n)*n,
|
||||
tag_string: tags[n-1],
|
||||
)
|
||||
|
||||
FactoryGirl.create(:artist_commentary, post: p)
|
||||
@@ -2112,6 +2115,11 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_tag_match(posts.reverse, "order:mpixels")
|
||||
assert_tag_match(posts.reverse, "order:portrait")
|
||||
assert_tag_match(posts.reverse, "order:filesize")
|
||||
assert_tag_match(posts.reverse, "order:tagcount")
|
||||
assert_tag_match(posts.reverse, "order:gentags")
|
||||
assert_tag_match(posts.reverse, "order:arttags")
|
||||
assert_tag_match(posts.reverse, "order:chartags")
|
||||
assert_tag_match(posts.reverse, "order:copytags")
|
||||
assert_tag_match(posts.reverse, "order:rank")
|
||||
|
||||
assert_tag_match(posts, "order:id_asc")
|
||||
@@ -2125,6 +2133,11 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_tag_match(posts, "order:mpixels_asc")
|
||||
assert_tag_match(posts, "order:landscape")
|
||||
assert_tag_match(posts, "order:filesize_asc")
|
||||
assert_tag_match(posts, "order:tagcount_asc")
|
||||
assert_tag_match(posts, "order:gentags_asc")
|
||||
assert_tag_match(posts, "order:arttags_asc")
|
||||
assert_tag_match(posts, "order:chartags_asc")
|
||||
assert_tag_match(posts, "order:copytags_asc")
|
||||
end
|
||||
|
||||
should "return posts for order:comment_bumped" do
|
||||
|
||||
Reference in New Issue
Block a user