search: replace calls to PostQueryBuilder#fast_count with PostQuery#fast_count.
Prepare a few more places for the new tag search parser.
This commit is contained in:
@@ -13,8 +13,7 @@ class DiscordSlashCommand
|
||||
|
||||
def call
|
||||
tags = params[:tags]
|
||||
query = PostQueryBuilder.new(tags, User.anonymous, tag_limit: nil).normalized_query
|
||||
count = query.fast_count(timeout: 9_000, estimate_count: false, skip_cache: true)
|
||||
count = PostQuery.new(tags).fast_count(timeout: 9_000, estimate_count: false, skip_cache: true)
|
||||
|
||||
respond_with("`#{tags}`: #{count} posts")
|
||||
end
|
||||
|
||||
@@ -3,15 +3,20 @@
|
||||
class PostQuery
|
||||
extend Memoist
|
||||
|
||||
attr_reader :search, :parser, :ast
|
||||
attr_reader :search, :parser, :builder, :ast
|
||||
delegate :tag_names, :metatags, to: :ast
|
||||
|
||||
def initialize(search)
|
||||
def initialize(search, current_user: User.anonymous, tag_limit: nil, safe_mode: false, hide_deleted_posts: false)
|
||||
@search = search
|
||||
@parser = Parser.new(search)
|
||||
@builder = PostQueryBuilder.new(search, current_user, tag_limit: tag_limit, safe_mode: safe_mode, hide_deleted_posts: hide_deleted_posts)
|
||||
@ast = parser.parse.simplify
|
||||
end
|
||||
|
||||
def fast_count(...)
|
||||
builder.normalized_query.fast_count(...)
|
||||
end
|
||||
|
||||
def tags
|
||||
Tag.where(name: tag_names)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user