PERF: Allow plugins to preload custom fields for topics in CategoryList.

This commit is contained in:
Guo Xiang Tan 2017-08-01 17:26:03 +09:00
parent 67882ec37d
commit 1197750e7d

View File

@ -3,6 +3,9 @@ require_dependency 'pinned_check'
class CategoryList
include ActiveModel::Serialization
cattr_accessor :preloaded_topic_custom_fields
self.preloaded_topic_custom_fields = Set.new
attr_accessor :categories,
:uncategorized,
:draft,
@ -20,6 +23,13 @@ class CategoryList
find_user_data
sort_unpinned
trim_results
if preloaded_topic_custom_fields.present?
Topic.preload_custom_fields(
@categories.map(&:displayable_topics).flatten,
preloaded_topic_custom_fields
)
end
end
def preload_key