Add attribute to grouped search results for more available posts.

This commit is contained in:
Jakub Macina 2017-07-20 18:07:13 +02:00
parent b534778f46
commit 7b40de5ac4
2 changed files with 6 additions and 3 deletions

View File

@ -2,7 +2,7 @@ class GroupedSearchResultSerializer < ApplicationSerializer
has_many :posts, serializer: SearchPostSerializer
has_many :users, serializer: SearchResultUserSerializer
has_many :categories, serializer: BasicCategorySerializer
attributes :more_posts, :more_users, :more_categories, :term, :search_log_id
attributes :more_posts, :more_users, :more_categories, :term, :search_log_id, :more_full_page_results
def search_log_id
object.search_log_id

View File

@ -19,7 +19,8 @@ class Search
:more_users,
:term,
:search_context,
:include_blurbs
:include_blurbs,
:more_full_page_results
)
attr_accessor :search_log_id
@ -50,7 +51,9 @@ class Search
def add(object)
type = object.class.to_s.downcase.pluralize
if !@type_filter.present? && send(type).length == Search.per_facet
if @type_filter.present? && send(type).length == Search.per_filter
@more_full_page_results = true
elsif !@type_filter.present? && send(type).length == Search.per_facet
instance_variable_set("@more_#{type}".to_sym, true)
else
(send type) << object