mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
PERF: Allow plugins to preload custom fields for topics in CategoryList
.
This commit is contained in:
parent
67882ec37d
commit
1197750e7d
@ -3,6 +3,9 @@ require_dependency 'pinned_check'
|
|||||||
class CategoryList
|
class CategoryList
|
||||||
include ActiveModel::Serialization
|
include ActiveModel::Serialization
|
||||||
|
|
||||||
|
cattr_accessor :preloaded_topic_custom_fields
|
||||||
|
self.preloaded_topic_custom_fields = Set.new
|
||||||
|
|
||||||
attr_accessor :categories,
|
attr_accessor :categories,
|
||||||
:uncategorized,
|
:uncategorized,
|
||||||
:draft,
|
:draft,
|
||||||
@ -20,6 +23,13 @@ class CategoryList
|
|||||||
find_user_data
|
find_user_data
|
||||||
sort_unpinned
|
sort_unpinned
|
||||||
trim_results
|
trim_results
|
||||||
|
|
||||||
|
if preloaded_topic_custom_fields.present?
|
||||||
|
Topic.preload_custom_fields(
|
||||||
|
@categories.map(&:displayable_topics).flatten,
|
||||||
|
preloaded_topic_custom_fields
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def preload_key
|
def preload_key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user