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:
@@ -616,30 +616,21 @@ class Post < ApplicationRecord
|
||||
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
||||
end
|
||||
|
||||
def set_tag_count(category,tagcount)
|
||||
self.send("tag_count_#{category}=",tagcount)
|
||||
end
|
||||
|
||||
def inc_tag_count(category)
|
||||
set_tag_count(category,self.send("tag_count_#{category}") + 1)
|
||||
end
|
||||
|
||||
def set_tag_counts
|
||||
self.tag_count = 0
|
||||
self.tag_count_general = 0
|
||||
self.tag_count_artist = 0
|
||||
self.tag_count_copyright = 0
|
||||
self.tag_count_character = 0
|
||||
|
||||
TagCategory.categories {|x| set_tag_count(x,0)}
|
||||
categories = Tag.categories_for(tag_array, :disable_caching => true)
|
||||
categories.each_value do |category|
|
||||
self.tag_count += 1
|
||||
|
||||
case category
|
||||
when Tag.categories.general
|
||||
self.tag_count_general += 1
|
||||
|
||||
when Tag.categories.artist
|
||||
self.tag_count_artist += 1
|
||||
|
||||
when Tag.categories.copyright
|
||||
self.tag_count_copyright += 1
|
||||
|
||||
when Tag.categories.character
|
||||
self.tag_count_character += 1
|
||||
end
|
||||
inc_tag_count(TagCategory.reverse_mapping[category])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -918,31 +909,11 @@ class Post < ApplicationRecord
|
||||
@tag_categories ||= Tag.categories_for(tag_array)
|
||||
end
|
||||
|
||||
def copyright_tags
|
||||
typed_tags("copyright")
|
||||
end
|
||||
|
||||
def character_tags
|
||||
typed_tags("character")
|
||||
end
|
||||
|
||||
def artist_tags
|
||||
typed_tags("artist")
|
||||
end
|
||||
|
||||
def artist_tags_excluding_hidden
|
||||
artist_tags - %w(banned_artist)
|
||||
end
|
||||
|
||||
def general_tags
|
||||
typed_tags("general")
|
||||
end
|
||||
|
||||
def typed_tags(name)
|
||||
@typed_tags ||= {}
|
||||
@typed_tags[name] ||= begin
|
||||
tag_array.select do |tag|
|
||||
tag_categories[tag] == Danbooru.config.tag_category_mapping[name]
|
||||
tag_categories[tag] == TagCategory.mapping[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -955,52 +926,36 @@ class Post < ApplicationRecord
|
||||
@humanized_essential_tag_string ||= Cache.get("hets-#{id}", 1.hour.to_i) do
|
||||
string = []
|
||||
|
||||
if character_tags.any?
|
||||
chartags = character_tags.slice(0, 5)
|
||||
if character_tags.length > 5
|
||||
chartags << "others"
|
||||
TagCategory.humanized_list.each do |category|
|
||||
typetags = typed_tags(category) - TagCategory.humanized_mapping[category]["exclusion"]
|
||||
if TagCategory.humanized_mapping[category]["slice"] > 0
|
||||
typetags = typetags.slice(0,TagCategory.humanized_mapping[category]["slice"]) + (typetags.length > TagCategory.humanized_mapping[category]["slice"] ? ["others"] : [])
|
||||
end
|
||||
chartags = chartags.map do |tag|
|
||||
tag.match(/^(.+?)(?:_\(.+\))?$/)[1]
|
||||
if TagCategory.humanized_mapping[category]["regexmap"] != //
|
||||
typetags = typetags.map do |tag|
|
||||
tag.match(TagCategory.humanized_mapping[category]["regexmap"])[1]
|
||||
end
|
||||
end
|
||||
string << chartags.to_sentence
|
||||
end
|
||||
|
||||
if copyright_tags.any?
|
||||
copytags = copyright_tags.slice(0, 5)
|
||||
if copyright_tags.length > 5
|
||||
copytags << "others"
|
||||
if typetags.any?
|
||||
if category != "copyright" || typed_tags("character").any?
|
||||
string << TagCategory.humanized_mapping[category]["formatstr"] % typetags.to_sentence
|
||||
else
|
||||
string << typetags.to_sentence
|
||||
end
|
||||
end
|
||||
copytags = copytags.to_sentence
|
||||
string << (character_tags.any? ? "(#{copytags})" : copytags)
|
||||
end
|
||||
|
||||
if artist_tags_excluding_hidden.any?
|
||||
string << "drawn by"
|
||||
string << artist_tags_excluding_hidden.to_sentence
|
||||
end
|
||||
|
||||
string.empty? ? "##{id}" : string.join(" ").tr("_", " ")
|
||||
end
|
||||
end
|
||||
|
||||
def tag_string_copyright
|
||||
copyright_tags.join(" ")
|
||||
end
|
||||
|
||||
def tag_string_character
|
||||
character_tags.join(" ")
|
||||
end
|
||||
|
||||
def tag_string_artist
|
||||
artist_tags.join(" ")
|
||||
end
|
||||
|
||||
def tag_string_general
|
||||
general_tags.join(" ")
|
||||
TagCategory.categories.each do |category|
|
||||
define_method("tag_string_#{category}") do
|
||||
typed_tags(category).join(" ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
module FavoriteMethods
|
||||
def clean_fav_string?
|
||||
true
|
||||
@@ -1182,15 +1137,10 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
module CountMethods
|
||||
def fix_post_counts
|
||||
def fix_post_counts(post)
|
||||
post.set_tag_counts
|
||||
post.update_columns(
|
||||
:tag_count => post.tag_count,
|
||||
:tag_count_general => post.tag_count_general,
|
||||
:tag_count_artist => post.tag_count_artist,
|
||||
:tag_count_copyright => post.tag_count_copyright,
|
||||
:tag_count_character => post.tag_count_character
|
||||
)
|
||||
args = Hash[TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}].update(:tag_count => post.tag_count)
|
||||
post.update_columns(args)
|
||||
end
|
||||
|
||||
def get_count_from_cache(tags)
|
||||
@@ -1572,7 +1522,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def method_attributes
|
||||
list = super + [:uploader_name, :has_large, :tag_string_artist, :tag_string_character, :tag_string_copyright, :tag_string_general, :has_visible_children, :children_ids]
|
||||
list = super + [:uploader_name, :has_large, :has_visible_children, :children_ids] + TagCategory.categories.map {|x| "tag_string_#{x}".to_sym}
|
||||
if visible?
|
||||
list += [:file_url, :large_file_url, :preview_file_url]
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Tag < ApplicationRecord
|
||||
COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 1000
|
||||
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype|flagger|-flagger|appealer|-appealer"
|
||||
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype|flagger|-flagger|appealer|-appealer|" +
|
||||
TagCategory.short_name_list.map {|x| "#{x}tags"}.join("|")
|
||||
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm|flagger|-flagger|appealer|-appealer"
|
||||
attr_accessible :category, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :is_locked, :as => [:moderator, :admin]
|
||||
@@ -26,18 +27,18 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
class CategoryMapping
|
||||
Danbooru.config.reverse_tag_category_mapping.each do |value, category|
|
||||
define_method(category.downcase) do
|
||||
TagCategory.reverse_mapping.each do |value, category|
|
||||
define_method(category) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def regexp
|
||||
@regexp ||= Regexp.compile(Danbooru.config.tag_category_mapping.keys.sort_by {|x| -x.size}.join("|"))
|
||||
@regexp ||= Regexp.compile(TagCategory.mapping.keys.sort_by {|x| -x.size}.join("|"))
|
||||
end
|
||||
|
||||
def value_for(string)
|
||||
Danbooru.config.tag_category_mapping[string.to_s.downcase] || 0
|
||||
TagCategory.mapping[string.to_s.downcase] || 0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,7 +125,7 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
def category_name
|
||||
Danbooru.config.reverse_tag_category_mapping[category]
|
||||
TagCategory.reverse_mapping[category].capitalize
|
||||
end
|
||||
|
||||
def update_category_cache_for_all
|
||||
@@ -140,7 +141,8 @@ class Tag < ApplicationRecord
|
||||
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)
|
||||
args = Hash[TagCategory.categories {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}].update(:tag_count => post.tag_count)
|
||||
Post.where(:id => post.id).update_all(args)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -175,7 +177,7 @@ class Tag < ApplicationRecord
|
||||
counts = counts.to_a.select {|x| x[1] > trending_count_limit}
|
||||
counts = counts.map do |tag_name, recent_count|
|
||||
tag = Tag.find_or_create_by_name(tag_name)
|
||||
if tag.category == Danbooru.config.tag_category_mapping["artist"]
|
||||
if tag.category == Tag.categories.artist
|
||||
# we're not interested in artists in the trending list
|
||||
[tag_name, 0]
|
||||
else
|
||||
@@ -317,19 +319,19 @@ class Tag < ApplicationRecord
|
||||
when :filesize
|
||||
object =~ /\A(\d+(?:\.\d*)?|\d*\.\d+)([kKmM]?)[bB]?\Z/
|
||||
|
||||
size = $1.to_f
|
||||
unit = $2
|
||||
size = $1.to_f
|
||||
unit = $2
|
||||
|
||||
conversion_factor = case unit
|
||||
when /m/i
|
||||
1024 * 1024
|
||||
when /k/i
|
||||
1024
|
||||
else
|
||||
1
|
||||
end
|
||||
conversion_factor = case unit
|
||||
when /m/i
|
||||
1024 * 1024
|
||||
when /k/i
|
||||
1024
|
||||
else
|
||||
1
|
||||
end
|
||||
|
||||
(size * conversion_factor).to_i
|
||||
(size * conversion_factor).to_i
|
||||
end
|
||||
end
|
||||
|
||||
@@ -429,296 +431,289 @@ class Tag < ApplicationRecord
|
||||
q[:tag_count] += 1 unless token == "status:deleted" || token =~ /\Alimit:.+\Z/
|
||||
|
||||
if token =~ /\A(#{METATAGS}):(.+)\Z/i
|
||||
case $1.downcase
|
||||
g1 = $1.downcase
|
||||
g2 = $2
|
||||
case g1
|
||||
when "-user"
|
||||
q[:uploader_id_neg] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:uploader_id_neg] << user_id unless user_id.blank?
|
||||
|
||||
when "user"
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:uploader_id] = user_id unless user_id.blank?
|
||||
|
||||
when "-approver"
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:approver_id] = "any"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:approver_id] = "none"
|
||||
else
|
||||
q[:approver_id_neg] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:approver_id_neg] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "approver"
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:approver_id] = "none"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:approver_id] = "any"
|
||||
else
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:approver_id] = user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "flagger"
|
||||
q[:flagger_ids] ||= []
|
||||
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:flagger_ids] << "none"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:flagger_ids] << "any"
|
||||
else
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:flagger_ids] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "-flagger"
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:flagger_ids] ||= []
|
||||
q[:flagger_ids] << "any"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:flagger_ids] ||= []
|
||||
q[:flagger_ids] << "none"
|
||||
else
|
||||
q[:flagger_ids_neg] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:flagger_ids_neg] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "appealer"
|
||||
q[:appealer_ids] ||= []
|
||||
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:appealer_ids] << "none"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:appealer_ids] << "any"
|
||||
else
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:appealer_ids] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "-appealer"
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:appealer_ids] ||= []
|
||||
q[:appealer_ids] << "any"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:appealer_ids] ||= []
|
||||
q[:appealer_ids] << "none"
|
||||
else
|
||||
q[:appealer_ids_neg] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:appealer_ids_neg] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "commenter", "comm"
|
||||
q[:commenter_ids] ||= []
|
||||
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:commenter_ids] << "none"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:commenter_ids] << "any"
|
||||
else
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:commenter_ids] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "noter"
|
||||
q[:noter_ids] ||= []
|
||||
|
||||
if $2 == "none"
|
||||
if g2 == "none"
|
||||
q[:noter_ids] << "none"
|
||||
elsif $2 == "any"
|
||||
elsif g2 == "any"
|
||||
q[:noter_ids] << "any"
|
||||
else
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:noter_ids] << user_id unless user_id.blank?
|
||||
end
|
||||
|
||||
when "noteupdater"
|
||||
q[:note_updater_ids] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:note_updater_ids] << user_id unless user_id.blank?
|
||||
|
||||
when "artcomm"
|
||||
q[:artcomm_ids] ||= []
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:artcomm_ids] << user_id unless user_id.blank?
|
||||
|
||||
when "-pool"
|
||||
if $2.downcase == "none"
|
||||
if g2.downcase == "none"
|
||||
q[:pool] = "any"
|
||||
elsif $2.downcase == "any"
|
||||
elsif g2.downcase == "any"
|
||||
q[:pool] = "none"
|
||||
elsif $2.downcase == "series"
|
||||
elsif g2.downcase == "series"
|
||||
q[:tags][:exclude] << "pool:series"
|
||||
elsif $2.downcase == "collection"
|
||||
elsif g2.downcase == "collection"
|
||||
q[:tags][:exclude] << "pool:collection"
|
||||
else
|
||||
q[:tags][:exclude] << "pool:#{Pool.name_to_id($2)}"
|
||||
q[:tags][:exclude] << "pool:#{Pool.name_to_id(g2)}"
|
||||
end
|
||||
|
||||
when "pool"
|
||||
if $2.downcase == "none"
|
||||
if g2.downcase == "none"
|
||||
q[:pool] = "none"
|
||||
elsif $2.downcase == "any"
|
||||
elsif g2.downcase == "any"
|
||||
q[:pool] = "any"
|
||||
elsif $2.downcase == "series"
|
||||
elsif g2.downcase == "series"
|
||||
q[:tags][:related] << "pool:series"
|
||||
elsif $2.downcase == "collection"
|
||||
elsif g2.downcase == "collection"
|
||||
q[:tags][:related] << "pool:collection"
|
||||
elsif $2.include?("*")
|
||||
pools = Pool.name_matches($2).select("id").limit(Danbooru.config.tag_query_limit).order("post_count DESC")
|
||||
elsif g2.include?("*")
|
||||
pools = Pool.name_matches(g2).select("id").limit(Danbooru.config.tag_query_limit).order("post_count DESC")
|
||||
q[:tags][:include] += pools.map {|pool| "pool:#{pool.id}"}
|
||||
else
|
||||
q[:tags][:related] << "pool:#{Pool.name_to_id($2)}"
|
||||
q[:tags][:related] << "pool:#{Pool.name_to_id(g2)}"
|
||||
end
|
||||
|
||||
when "ordpool"
|
||||
pool_id = Pool.name_to_id($2)
|
||||
pool_id = Pool.name_to_id(g2)
|
||||
q[:tags][:related] << "pool:#{pool_id}"
|
||||
q[:ordpool] = pool_id
|
||||
|
||||
when "-favgroup"
|
||||
favgroup_id = FavoriteGroup.name_to_id($2)
|
||||
favgroup_id = FavoriteGroup.name_to_id(g2)
|
||||
q[:favgroups_neg] ||= []
|
||||
q[:favgroups_neg] << favgroup_id
|
||||
|
||||
when "favgroup"
|
||||
favgroup_id = FavoriteGroup.name_to_id($2)
|
||||
favgroup_id = FavoriteGroup.name_to_id(g2)
|
||||
q[:favgroups] ||= []
|
||||
q[:favgroups] << favgroup_id
|
||||
|
||||
when "-fav"
|
||||
q[:tags][:exclude] << "fav:#{User.name_to_id($2)}"
|
||||
q[:tags][:exclude] << "fav:#{User.name_to_id(g2)}"
|
||||
|
||||
when "fav"
|
||||
q[:tags][:related] << "fav:#{User.name_to_id($2)}"
|
||||
q[:tags][:related] << "fav:#{User.name_to_id(g2)}"
|
||||
|
||||
when "ordfav"
|
||||
user_id = User.name_to_id($2)
|
||||
user_id = User.name_to_id(g2)
|
||||
q[:tags][:related] << "fav:#{user_id}"
|
||||
q[:ordfav] = user_id
|
||||
|
||||
when "search"
|
||||
q[:saved_searches] ||= []
|
||||
q[:saved_searches] << $2
|
||||
q[:saved_searches] << g2
|
||||
|
||||
when "md5"
|
||||
q[:md5] = $2.downcase.split(/,/)
|
||||
q[:md5] = g2.downcase.split(/,/)
|
||||
|
||||
when "-rating"
|
||||
q[:rating_negated] = $2.downcase
|
||||
q[:rating_negated] = g2.downcase
|
||||
|
||||
when "rating"
|
||||
q[:rating] = $2.downcase
|
||||
q[:rating] = g2.downcase
|
||||
|
||||
when "-locked"
|
||||
q[:locked_negated] = $2.downcase
|
||||
q[:locked_negated] = g2.downcase
|
||||
|
||||
when "locked"
|
||||
q[:locked] = $2.downcase
|
||||
q[:locked] = g2.downcase
|
||||
|
||||
when "id"
|
||||
q[:post_id] = parse_helper($2)
|
||||
q[:post_id] = parse_helper(g2)
|
||||
|
||||
when "-id"
|
||||
q[:post_id_negated] = $2.to_i
|
||||
q[:post_id_negated] = g2.to_i
|
||||
|
||||
when "width"
|
||||
q[:width] = parse_helper($2)
|
||||
q[:width] = parse_helper(g2)
|
||||
|
||||
when "height"
|
||||
q[:height] = parse_helper($2)
|
||||
q[:height] = parse_helper(g2)
|
||||
|
||||
when "mpixels"
|
||||
q[:mpixels] = parse_helper_fudged($2, :float)
|
||||
q[:mpixels] = parse_helper_fudged(g2, :float)
|
||||
|
||||
when "ratio"
|
||||
q[:ratio] = parse_helper($2, :ratio)
|
||||
q[:ratio] = parse_helper(g2, :ratio)
|
||||
|
||||
when "score"
|
||||
q[:score] = parse_helper($2)
|
||||
q[:score] = parse_helper(g2)
|
||||
|
||||
when "favcount"
|
||||
q[:fav_count] = parse_helper($2)
|
||||
q[:fav_count] = parse_helper(g2)
|
||||
|
||||
when "filesize"
|
||||
q[:filesize] = parse_helper_fudged($2, :filesize)
|
||||
q[:filesize] = parse_helper_fudged(g2, :filesize)
|
||||
|
||||
when "source"
|
||||
src = $2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
src = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
|
||||
when "-source"
|
||||
src = $2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
src = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source_neg] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
|
||||
when "date"
|
||||
q[:date] = parse_helper($2, :date)
|
||||
q[:date] = parse_helper(g2, :date)
|
||||
|
||||
when "age"
|
||||
q[:age] = reverse_parse_helper(parse_helper($2, :age))
|
||||
q[:age] = reverse_parse_helper(parse_helper(g2, :age))
|
||||
|
||||
when "tagcount"
|
||||
q[:post_tag_count] = parse_helper($2)
|
||||
q[:post_tag_count] = parse_helper(g2)
|
||||
|
||||
when "gentags"
|
||||
q[:general_tag_count] = parse_helper($2)
|
||||
|
||||
when "arttags"
|
||||
q[:artist_tag_count] = parse_helper($2)
|
||||
|
||||
when "chartags"
|
||||
q[:character_tag_count] = parse_helper($2)
|
||||
|
||||
when "copytags"
|
||||
q[:copyright_tag_count] = parse_helper($2)
|
||||
when /(#{TagCategory.short_name_regex})tags/
|
||||
q["#{TagCategory.short_name_mapping[$1]}_tag_count".to_sym] = parse_helper(g2)
|
||||
|
||||
when "parent"
|
||||
q[:parent] = $2.downcase
|
||||
q[:parent] = g2.downcase
|
||||
|
||||
when "-parent"
|
||||
if $2.downcase == "none"
|
||||
if g2.downcase == "none"
|
||||
q[:parent] = "any"
|
||||
elsif $2.downcase == "any"
|
||||
elsif g2.downcase == "any"
|
||||
q[:parent] = "none"
|
||||
else
|
||||
q[:parent_neg_ids] ||= []
|
||||
q[:parent_neg_ids] << $2.downcase
|
||||
q[:parent_neg_ids] << g2.downcase
|
||||
end
|
||||
|
||||
when "child"
|
||||
q[:child] = $2.downcase
|
||||
q[:child] = g2.downcase
|
||||
|
||||
when "order"
|
||||
q[:order] = $2.downcase
|
||||
q[:order] = g2.downcase
|
||||
|
||||
when "limit"
|
||||
# Do nothing. The controller takes care of it.
|
||||
|
||||
when "-status"
|
||||
q[:status_neg] = $2.downcase
|
||||
q[:status_neg] = g2.downcase
|
||||
|
||||
when "status"
|
||||
q[:status] = $2.downcase
|
||||
q[:status] = g2.downcase
|
||||
|
||||
when "filetype"
|
||||
q[:filetype] = $2.downcase
|
||||
q[:filetype] = g2.downcase
|
||||
|
||||
when "-filetype"
|
||||
q[:filetype_neg] = $2.downcase
|
||||
q[:filetype_neg] = g2.downcase
|
||||
|
||||
when "pixiv_id", "pixiv"
|
||||
q[:pixiv_id] = parse_helper($2)
|
||||
q[:pixiv_id] = parse_helper(g2)
|
||||
|
||||
when "upvote"
|
||||
if CurrentUser.user.is_moderator?
|
||||
q[:upvote] = User.name_to_id($2)
|
||||
q[:upvote] = User.name_to_id(g2)
|
||||
end
|
||||
|
||||
when "downvote"
|
||||
if CurrentUser.user.is_moderator?
|
||||
q[:downvote] = User.name_to_id($2)
|
||||
q[:downvote] = User.name_to_id(g2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user