mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Allow plugins to preload custom fields for topics in CategoryList.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user