search: drop special case for pixiv urls in source: metatag.
* Drop support for `source:pixiv/artist-name` searches. This was a hack that only worked on old pixiv urls that haven't been used for years. * Replace the old SourcePattern(lower(source)) index with a trigram index.
This commit is contained in:
@@ -195,30 +195,19 @@ class PostQueryBuilder
|
||||
relation = relation.where.not("posts.file_ext": q[:filetype_neg])
|
||||
end
|
||||
|
||||
# The SourcePattern SQL function replaces Pixiv sources with "pixiv/[suffix]", where
|
||||
# [suffix] is everything past the second-to-last slash in the URL. It leaves non-Pixiv
|
||||
# URLs unchanged. This is to ease database load for Pixiv source searches.
|
||||
if q[:source]
|
||||
if q[:source] == "none%"
|
||||
if q[:source] == "none"
|
||||
relation = relation.where("posts.source = ''")
|
||||
elsif q[:source] == "http%"
|
||||
relation = relation.where("(lower(posts.source) like ?)", "http%")
|
||||
elsif q[:source] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i
|
||||
relation = relation.where("SourcePattern(lower(posts.source)) LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1)
|
||||
else
|
||||
relation = relation.where("SourcePattern(lower(posts.source)) LIKE SourcePattern(lower(?)) ESCAPE E'\\\\'", q[:source])
|
||||
relation = relation.where_ilike(:source, q[:source].downcase + "*")
|
||||
end
|
||||
end
|
||||
|
||||
if q[:source_neg]
|
||||
if q[:source_neg] == "none%"
|
||||
if q[:source_neg] == "none"
|
||||
relation = relation.where("posts.source != ''")
|
||||
elsif q[:source_neg] == "http%"
|
||||
relation = relation.where("(lower(posts.source) not like ?)", "http%")
|
||||
elsif q[:source_neg] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i
|
||||
relation = relation.where("SourcePattern(lower(posts.source)) NOT LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1)
|
||||
else
|
||||
relation = relation.where("SourcePattern(lower(posts.source)) NOT LIKE SourcePattern(lower(?)) ESCAPE E'\\\\'", q[:source_neg])
|
||||
relation = relation.where_not_ilike(:source, q[:source_neg].downcase + "*")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -751,12 +751,10 @@ class Tag < ApplicationRecord
|
||||
q[:filesize] = parse_helper_fudged(g2, :filesize)
|
||||
|
||||
when "source"
|
||||
src = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
q[:source] = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
|
||||
when "-source"
|
||||
src = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
q[:source_neg] = (src.to_escaped_for_sql_like + "%").gsub(/%+/, '%')
|
||||
q[:source_neg] = g2.gsub(/\A"(.*)"\Z/, '\1')
|
||||
|
||||
when "date"
|
||||
q[:date] = parse_helper(g2, :date)
|
||||
|
||||
Reference in New Issue
Block a user