diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c87fe15c6..fd57fb78d 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -9,7 +9,7 @@ class PostsController < ApplicationController format.html { redirect_to(@post) } end else - @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], raw: params[:raw], random: params[:random], format: params[:format], read_only: params[:ro]) + @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], raw: params[:raw], random: params[:random], format: params[:format]) @posts = @post_set.posts respond_with(@posts) do |format| format.atom diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index ec92c6270..abae53942 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -1,7 +1,7 @@ module PostSets class Post < PostSets::Base MAX_PER_PAGE = 200 - attr_reader :tag_array, :page, :raw, :random, :post_count, :format, :read_only + attr_reader :tag_array, :page, :raw, :random, :post_count, :format def initialize(tags, page = 1, per_page = nil, options = {}) @tag_array = Tag.scan_query(tags) @@ -10,7 +10,6 @@ module PostSets @raw = options[:raw].present? @random = options[:random].present? @format = options[:format] || "html" - @read_only = options[:read_only] end def tag_string @@ -134,7 +133,7 @@ module PostSets elsif raw temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").where("true /* PostSets::Post#posts:1 */").paginate(page, :count => post_count, :limit => per_page) else - temp = ::Post.tag_match(tag_string, read_only).where("true /* PostSets::Post#posts:2 */").paginate(page, :count => post_count, :limit => per_page) + temp = ::Post.tag_match(tag_string).where("true /* PostSets::Post#posts:2 */").paginate(page, :count => post_count, :limit => per_page) end temp.each # hack to force rails to eager load temp diff --git a/app/models/post.rb b/app/models/post.rb index ed05adab0..0643d3f9a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb index 62247f1b6..3f5882ae0 100644 --- a/app/models/saved_search.rb +++ b/app/models/saved_search.rb @@ -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