Skip to content

A platform for community discussion. Free, open, simple.

PERF: fix N+1 queries for non-JS topic view.

Vinoth Kannanf9f12ed221f4
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb
index 5e8ce1a5fed..9d921c58bc7 100644
--- a/app/views/topics/show.html.erb
+++ b/app/views/topics/show.html.erb
@@ -46,7 +46,8 @@
<a itemprop="url" href='<%= Discourse.base_uri %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a>
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
<%
- who_username = post.custom_fields["action_code_who"] || ""
+ post_custom_fields = @topic_view.post_custom_fields[post.id] || {}
+ who_username = post_custom_fields["action_code_who"] || ""
if post.action_code
%>
<%= t("js.action_codes.#{post.action_code}", when: "", who: who_username).html_safe %>