Post#tag_match: clean up read_only param.
* Drop /posts?ro=true param (broken). * Clean up tag_match (rescuing PG::ConnectionBad didn't do anything, we just build the query here, we don't run it).
This commit is contained in:
@@ -1682,21 +1682,8 @@ class Post < ApplicationRecord
|
||||
where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery)
|
||||
end
|
||||
|
||||
def tag_match(query, read_only = false)
|
||||
if query =~ /status:deleted.status:deleted/
|
||||
# temp fix for degenerate crawlers
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
if read_only
|
||||
begin
|
||||
PostQueryBuilder.new(query, read_only: true).build
|
||||
rescue PG::ConnectionBad
|
||||
PostQueryBuilder.new(query).build
|
||||
end
|
||||
else
|
||||
PostQueryBuilder.new(query).build
|
||||
end
|
||||
def tag_match(query, read_only: false)
|
||||
PostQueryBuilder.new(query, read_only: read_only).build
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class SavedSearch < ApplicationRecord
|
||||
CurrentUser.as_system do
|
||||
redis_key = "search:#{query}"
|
||||
return if redis.exists(redis_key)
|
||||
post_ids = Post.tag_match(query, true).limit(QUERY_LIMIT).pluck(:id)
|
||||
post_ids = Post.tag_match(query, read_only: true).limit(QUERY_LIMIT).pluck(:id)
|
||||
redis.sadd(redis_key, post_ids)
|
||||
redis.expire(redis_key, REDIS_EXPIRY)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user