users: remove 'hide deleted posts' account setting.
This setting automatically added the `-status:deleted` metatag to all searches. This meant deleted posts were filtered out at the database level, rather than at the html level. This way searches wouldn't have less-than-full pages. The cost was that searches were slower, mainly because post counts weren't cached. Normally when you search for a tag, we can get the post count from the tags table. If the search is actually like `touhou -status:deleted`, then we don't know the count and we have to calculate it on demand. This option is being removed because it did the opposite of what people thought it did. People thought it made deleted posts visible, when actually it made them more hidden.
This commit is contained in:
@@ -16,11 +16,10 @@ class PostQuery
|
||||
SINGLETON_METATAGS = ORDER_METATAGS + %w[limit random]
|
||||
|
||||
attr_reader :current_user
|
||||
private attr_reader :tag_limit, :safe_mode, :hide_deleted_posts, :builder
|
||||
private attr_reader :tag_limit, :safe_mode, :builder
|
||||
|
||||
delegate :tag?, :metatag?, :wildcard?, :metatags, :wildcards, :tag_names, :to_infix, :to_pretty_string, to: :ast
|
||||
alias_method :safe_mode?, :safe_mode
|
||||
alias_method :hide_deleted_posts?, :hide_deleted_posts
|
||||
alias_method :to_s, :to_infix
|
||||
|
||||
# Return a new PostQuery with aliases replaced.
|
||||
@@ -42,7 +41,7 @@ class PostQuery
|
||||
PostQuery.normalize(search, ...).with_implicit_metatags.posts
|
||||
end
|
||||
|
||||
def initialize(search_or_ast, current_user: User.anonymous, tag_limit: nil, safe_mode: false, hide_deleted_posts: false)
|
||||
def initialize(search_or_ast, current_user: User.anonymous, tag_limit: nil, safe_mode: false)
|
||||
if search_or_ast.is_a?(AST)
|
||||
@ast = search_or_ast
|
||||
else
|
||||
@@ -52,16 +51,15 @@ class PostQuery
|
||||
@current_user = current_user
|
||||
@tag_limit = tag_limit
|
||||
@safe_mode = safe_mode
|
||||
@hide_deleted_posts = hide_deleted_posts
|
||||
end
|
||||
|
||||
# Build a new PostQuery from the given AST and the current settings.
|
||||
def build(ast)
|
||||
PostQuery.new(ast, current_user: current_user, tag_limit: tag_limit, safe_mode: safe_mode, hide_deleted_posts: hide_deleted_posts)
|
||||
PostQuery.new(ast, current_user: current_user, tag_limit: tag_limit, safe_mode: safe_mode)
|
||||
end
|
||||
|
||||
def builder
|
||||
@builder ||= PostQueryBuilder.new(search, current_user, tag_limit: tag_limit, safe_mode: safe_mode, hide_deleted_posts: hide_deleted_posts)
|
||||
@builder ||= PostQueryBuilder.new(search, current_user, tag_limit: tag_limit, safe_mode: safe_mode)
|
||||
end
|
||||
|
||||
def search
|
||||
@@ -189,19 +187,17 @@ class PostQuery
|
||||
TagAlias.aliases_for(tag_names)
|
||||
end
|
||||
|
||||
# Implicit metatags are metatags added by the user's account settings. rating:s is implicit
|
||||
# under safe mode. -status:deleted is implicit when the "hide deleted posts" setting is on.
|
||||
# Implicit metatags are metatags added by the user's account settings. rating:s is implicit under safe mode.
|
||||
def implicit_metatags
|
||||
metatags = []
|
||||
metatags << AST.metatag("rating", "s") if safe_mode?
|
||||
metatags << -AST.metatag("status", "deleted") if hide_deleted?
|
||||
metatags
|
||||
end
|
||||
|
||||
# XXX unify with PostSets::Post#show_deleted?
|
||||
def hide_deleted?
|
||||
has_status_metatag = select_metatags(:status).any? { |metatag| metatag.value.downcase.in?(%w[deleted active any all unmoderated modqueue appealed]) }
|
||||
hide_deleted_posts? && !has_status_metatag
|
||||
!has_status_metatag
|
||||
end
|
||||
|
||||
concerning :CountMethods do
|
||||
|
||||
@@ -70,22 +70,19 @@ class PostQueryBuilder
|
||||
COUNT_METATAG_SYNONYMS.flat_map { |str| [str, "#{str}_asc"] } +
|
||||
CATEGORY_COUNT_METATAGS.flat_map { |str| [str, "#{str}_asc"] }
|
||||
|
||||
attr_reader :query_string, :current_user, :tag_limit, :safe_mode, :hide_deleted_posts
|
||||
attr_reader :query_string, :current_user, :tag_limit, :safe_mode
|
||||
alias_method :safe_mode?, :safe_mode
|
||||
alias_method :hide_deleted_posts?, :hide_deleted_posts
|
||||
|
||||
# Initialize a post query.
|
||||
# @param query_string [String] the tag search
|
||||
# @param current_user [User] the user performing the search
|
||||
# @param tag_limit [Integer] the user's tag limit
|
||||
# @param safe_mode [Boolean] whether safe mode is enabled. if true, return only rating:s posts.
|
||||
# @param hide_deleted_posts [Boolean] if true, filter out status:deleted posts.
|
||||
def initialize(query_string, current_user = User.anonymous, tag_limit: nil, safe_mode: false, hide_deleted_posts: false)
|
||||
def initialize(query_string, current_user = User.anonymous, tag_limit: nil, safe_mode: false)
|
||||
@query_string = query_string
|
||||
@current_user = current_user
|
||||
@tag_limit = tag_limit
|
||||
@safe_mode = safe_mode
|
||||
@hide_deleted_posts = hide_deleted_posts
|
||||
end
|
||||
|
||||
def metatag_matches(name, value, relation = Post.all, quoted: false)
|
||||
|
||||
@@ -17,8 +17,8 @@ module PostSets
|
||||
alias_method :show_votes?, :show_votes
|
||||
|
||||
def initialize(tags, page = 1, per_page = nil, user: CurrentUser.user, format: "html", show_votes: false)
|
||||
@query = PostQueryBuilder.new(tags, user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?, hide_deleted_posts: user.hide_deleted_posts?)
|
||||
@post_query = PostQuery.normalize(tags, current_user: user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?, hide_deleted_posts: user.hide_deleted_posts?)
|
||||
@query = PostQueryBuilder.new(tags, user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?)
|
||||
@post_query = PostQuery.normalize(tags, current_user: user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?)
|
||||
@normalized_query = post_query.with_implicit_metatags
|
||||
@tag_string = tags
|
||||
@page = page
|
||||
|
||||
@@ -57,7 +57,6 @@ class UserDeletion
|
||||
user.last_forum_read_at = nil
|
||||
user.favorite_tags = ""
|
||||
user.blacklisted_tags = ""
|
||||
user.hide_deleted_posts = false
|
||||
user.show_deleted_children = false
|
||||
user.time_zone = "Eastern Time (US & Canada)"
|
||||
user.save!
|
||||
|
||||
Reference in New Issue
Block a user