Merge pull request #3353 from BrokenEagle/feat-add-meta-tag-category

Migrated tag logic into config file and added fifth tag category meta
This commit is contained in:
Albert Yi
2017-11-13 11:44:15 -08:00
committed by GitHub
22 changed files with 384 additions and 359 deletions

View File

@@ -118,10 +118,9 @@ class PostQueryBuilder
relation = add_range_relation(q[:filesize], "posts.file_size", relation)
relation = add_range_relation(q[:date], "posts.created_at", relation)
relation = add_range_relation(q[:age], "posts.created_at", relation)
relation = add_range_relation(q[:general_tag_count], "posts.tag_count_general", relation)
relation = add_range_relation(q[:artist_tag_count], "posts.tag_count_artist", relation)
relation = add_range_relation(q[:copyright_tag_count], "posts.tag_count_copyright", relation)
relation = add_range_relation(q[:character_tag_count], "posts.tag_count_character", relation)
TagCategory.categories.each do |category|
relation = add_range_relation(q["#{category}_tag_count".to_sym], "posts.tag_count_#{category}", relation)
end
relation = add_range_relation(q[:post_tag_count], "posts.tag_count", relation)
relation = add_range_relation(q[:pixiv_id], "posts.pixiv_id", relation)
@@ -513,29 +512,11 @@ class PostQueryBuilder
when "tagcount_asc"
relation = relation.order("posts.tag_count ASC")
when "gentags", "gentags_desc"
relation = relation.order("posts.tag_count_general DESC")
when /(#{TagCategory.short_name_regex})tags(?:\Z|_desc)/
relation = relation.order("posts.tag_count_#{TagCategory.short_name_mapping[$1]} 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 /(#{TagCategory.short_name_regex})tags_asc/
relation = relation.order("posts.tag_count_#{TagCategory.short_name_mapping[$1]} 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")