FIX: Incorrect search blurb when advanced search filters are used take2

Also remove include_blurbs attribute which isn't used.
This commit is contained in:
Guo Xiang Tan
2020-07-14 11:05:57 +08:00
parent 919c87a9ce
commit ce39733b1a
6 changed files with 65 additions and 36 deletions

View File

@@ -35,7 +35,6 @@ class SearchController < ApplicationController
search_args = {
type_filter: 'topic',
guardian: guardian,
include_blurbs: true,
blurb_length: 300,
page: if params[:page].to_i <= 10
[params[:page].to_i, 1].max
@@ -53,10 +52,20 @@ class SearchController < ApplicationController
search_args[:user_id] = current_user.id if current_user.present?
if rate_limit_errors
result = Search::GroupedSearchResults.new(search_args[:type_filter], @search_term, context, false, 0)
result = Search::GroupedSearchResults.new(
type_filter: search_args[:type_filter],
term: @search_term,
search_context: context
)
result.error = I18n.t("rate_limiter.slow_down")
elsif site_overloaded?
result = Search::GroupedSearchResults.new(search_args[:type_filter], @search_term, context, false, 0)
result = Search::GroupedSearchResults.new(
type_filter: search_args[:type_filter],
term: @search_term,
search_context: context
)
result.error = I18n.t("search.extreme_load_error")
else
search = Search.new(@search_term, search_args)
@@ -90,7 +99,6 @@ class SearchController < ApplicationController
search_args = { guardian: guardian }
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
search_args[:include_blurbs] = params[:include_blurbs] == "true" if params[:include_blurbs].present?
search_args[:search_for_id] = true if params[:search_for_id].present?
context, type = lookup_search_context
@@ -106,10 +114,19 @@ class SearchController < ApplicationController
search_args[:restrict_to_archetype] = params[:restrict_to_archetype] if params[:restrict_to_archetype].present?
if rate_limit_errors
result = Search::GroupedSearchResults.new(search_args[:type_filter], @search_term, context, false, 0)
result = Search::GroupedSearchResults.new(
type_filter: search_args[:type_filter],
term: params[:term],
search_context: context
)
result.error = I18n.t("rate_limiter.slow_down")
elsif site_overloaded?
result = GroupedSearchResults.new(search_args["type_filter"], params[:term], context, false, 0)
result = GroupedSearchResults.new(
type_filter: search_args["type_filter"],
term: params[:term],
search_context: context
)
else
search = Search.new(params[:term], search_args)
result = search.execute