DEV: Option to preload topic custom fields in Search class

This commit is contained in:
Vinoth Kannan 2019-03-17 23:16:09 +05:30
parent f974bf714e
commit daf5a268a7
1 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,9 @@ class Search
INDEX_VERSION = 2.freeze
DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
cattr_accessor :preloaded_topic_custom_fields
self.preloaded_topic_custom_fields = Set.new
def self.per_facet
5
end
@ -242,6 +245,11 @@ class Search
find_grouped_results unless @results.posts.present?
if preloaded_topic_custom_fields.present? && @results.posts.present?
topics = @results.posts.map(&:topic)
Topic.preload_custom_fields(topics, preloaded_topic_custom_fields)
end
@results
end