Skip to content

Commit 8fdf6e9

Browse files
fbacallCopilot
andauthored
Eager load topics. Avoid n+1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d942806 commit 8fdf6e9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/views/learning_paths/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
</div>
6262

6363
<div class="learning-path-topics">
64-
<% topics = @learning_path.topic_links.joins(:topic) %>
65-
<% topic_count = topics.count %>
64+
<% topics = @learning_path.topic_links.includes(topic: :material_items).load %>
65+
<% topic_count = topics.size %>
6666
<% topics.each do |lpt| %>
6767
<% classes = ['learning-path-topic'] %>
6868
<% classes << 'single-topic' if topic_count == 1 %>

0 commit comments

Comments
 (0)