mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
avoid N+1 query even if no custom fields exist
This commit is contained in:
parent
0369f26a39
commit
539ca73668
@ -292,8 +292,12 @@ class PostSerializer < BasicPostSerializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_custom_fields
|
def post_custom_fields
|
||||||
@post_custom_fields ||= (@topic_view.present? && @topic_view.post_custom_fields.present?) ? @topic_view.post_custom_fields[object.id] : nil
|
@post_custom_fields ||=
|
||||||
@post_custom_fields ||= object.custom_fields
|
if @topic_view
|
||||||
|
@topic_view.post_custom_fields && @topic_view.post_custom_fields[object.id]
|
||||||
|
else
|
||||||
|
object.custom_fields
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user