search: refactor PostQueryBuilder class methods into instance methods.

* Make scan_query, parse_query, normalize_query into instance methods
  instead of class methods. This is to a) clean up the API and b)
  prepare for moving certain tag utility methods into PostQueryBuilder.

* Fix a few cases where a caller used scan_query when they should have
  used split_query or parse_tag_edit.
This commit is contained in:
evazion
2020-04-22 19:38:17 -05:00
parent d355c0e221
commit 3dab648d0e
10 changed files with 534 additions and 532 deletions

View File

@@ -25,7 +25,7 @@ module PostsHelper
return unless post_search_counts_enabled?
return unless params[:action] == "index" && params[:page].nil? && params[:tags].present?
tags = PostQueryBuilder.normalize_query(params[:tags])
tags = PostQueryBuilder.new(params[:tags]).normalize_query
sig = generate_reportbooru_signature("ps-#{tags}")
render "posts/partials/index/search_count", sig: sig
end
@@ -63,7 +63,7 @@ module PostsHelper
end
def show_tag_change_notice?
CurrentUser.user.is_member? && PostQueryBuilder.scan_query(params[:tags]).size == 1 && TagChangeNoticeService.get_forum_topic_id(params[:tags])
CurrentUser.user.is_member? && PostQueryBuilder.new(params[:tags]).split_query.size == 1 && TagChangeNoticeService.get_forum_topic_id(params[:tags])
end
private