Merge pull request #4271 from BrokenEagle/embedded-notes-search

Add search for embedded notes status
This commit is contained in:
evazion
2020-01-25 13:40:52 -06:00
committed by GitHub
4 changed files with 15 additions and 2 deletions

View File

@@ -118,6 +118,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
case "parent": case "parent":
case "filetype": case "filetype":
case "disapproval": case "disapproval":
case "embedded":
results = Autocomplete.static_metatag_source(term, metatag); results = Autocomplete.static_metatag_source(term, metatag);
break; break;
case "user": case "user":
@@ -272,6 +273,9 @@ Autocomplete.static_metatags = {
locked: [ locked: [
"rating", "note", "status" "rating", "note", "status"
], ],
embedded: [
"true", "false"
],
child: [ child: [
"any", "none" "any", "none"
], ],

View File

@@ -32,7 +32,7 @@ module Danbooru
bits = attributes.length bits = attributes.length
bit_index = bits - attributes.index(flag.to_s) - 1 bit_index = bits - attributes.index(flag.to_s) - 1
where(sanitize_sql(["get_bit(bit_prefs::bit(?), ?) = ?", bits, bit_index, value])) where(sanitize_sql(["get_bit(#{field}::bit(?), ?) = ?", bits, bit_index, value]))
end end
end end
end end

View File

@@ -440,6 +440,12 @@ class PostQueryBuilder
relation = relation.where("posts.is_status_locked = FALSE") relation = relation.where("posts.is_status_locked = FALSE")
end end
if q[:embedded] == "true"
relation = relation.bit_flags_match(:has_embedded_notes, true)
elsif q[:embedded] == "false"
relation = relation.bit_flags_match(:has_embedded_notes, false)
end
relation = add_tag_string_search_relation(q[:tags], relation) relation = add_tag_string_search_relation(q[:tags], relation)
if q[:ordpool].present? if q[:ordpool].present?

View File

@@ -17,7 +17,7 @@ class Tag < ApplicationRecord
-locked locked width height mpixels ratio score favcount filesize source -locked locked width height mpixels ratio score favcount filesize source
-source id -id date age order limit -status status tagcount parent -parent -source id -id date age order limit -status status tagcount parent -parent
child pixiv_id pixiv search upvote downvote filetype -filetype flagger child pixiv_id pixiv search upvote downvote filetype -filetype flagger
-flagger appealer -appealer disapproval -disapproval -flagger appealer -appealer disapproval -disapproval embedded
] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + COUNT_METATAG_SYNONYMS ] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + COUNT_METATAG_SYNONYMS
SUBQUERY_METATAGS = %w[commenter comm noter noteupdater artcomm flagger -flagger appealer -appealer] SUBQUERY_METATAGS = %w[commenter comm noter noteupdater artcomm flagger -flagger appealer -appealer]
@@ -739,6 +739,9 @@ class Tag < ApplicationRecord
when "status" when "status"
q[:status] = g2.downcase q[:status] = g2.downcase
when "embedded"
q[:embedded] = g2.downcase
when "filetype" when "filetype"
q[:filetype] = g2.downcase q[:filetype] = g2.downcase