2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 04:15:08 -05:00
|
|
|
class GroupedSearchResultSerializer < ApplicationSerializer
|
|
|
|
has_many :posts, serializer: SearchPostSerializer
|
2017-02-13 09:10:28 -06:00
|
|
|
has_many :users, serializer: SearchResultUserSerializer
|
2014-09-02 04:15:08 -05:00
|
|
|
has_many :categories, serializer: BasicCategorySerializer
|
2017-08-25 10:52:18 -05:00
|
|
|
has_many :tags, serializer: TagSerializer
|
2019-03-04 03:30:09 -06:00
|
|
|
has_many :groups, serializer: BasicGroupSerializer
|
2019-07-01 20:21:52 -05:00
|
|
|
attributes :more_posts,
|
|
|
|
:more_users,
|
|
|
|
:more_categories,
|
|
|
|
:term,
|
|
|
|
:search_log_id,
|
|
|
|
:more_full_page_results,
|
|
|
|
:can_create_topic,
|
2024-02-21 09:29:47 -06:00
|
|
|
:error,
|
|
|
|
:extra
|
2017-07-17 10:57:13 -05:00
|
|
|
|
|
|
|
def search_log_id
|
|
|
|
object.search_log_id
|
|
|
|
end
|
|
|
|
|
2017-07-17 14:42:32 -05:00
|
|
|
def include_search_log_id?
|
|
|
|
search_log_id.present?
|
|
|
|
end
|
|
|
|
|
2017-08-25 10:52:18 -05:00
|
|
|
def include_tags?
|
|
|
|
SiteSetting.tagging_enabled
|
|
|
|
end
|
|
|
|
|
2017-11-10 14:38:54 -06:00
|
|
|
def can_create_topic
|
|
|
|
scope.can_create?(Topic)
|
|
|
|
end
|
2024-02-21 09:29:47 -06:00
|
|
|
|
|
|
|
def extra
|
|
|
|
extra = {}
|
|
|
|
|
|
|
|
if object.can_lazy_load_categories
|
|
|
|
extra[:categories] = ActiveModel::ArraySerializer.new(
|
|
|
|
object.extra_categories,
|
|
|
|
each_serializer: BasicCategorySerializer,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
extra
|
|
|
|
end
|
2014-09-02 04:15:08 -05:00
|
|
|
end
|