Commit d5f2b32a authored by Markus Koller's avatar Markus Koller Committed by Douglas Barbosa Alexandre

Avoid N+1 queries in breadcrumbs

parent 08e972e0
......@@ -120,7 +120,9 @@ module GroupsHelper
@has_group_title = true
full_title = []
group.ancestors.reverse.each_with_index do |parent, index|
ancestors = group.ancestors.with_route
ancestors.reverse_each.with_index do |parent, index|
if index > 0
add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before)
else
......
---
title: Avoid N+1 queries in breadcrumbs
merge_request: 57725
author:
type: performance
......@@ -109,6 +109,16 @@ RSpec.describe GroupsHelper do
subject
end
it 'avoids N+1 queries' do
control_count = ActiveRecord::QueryRecorder.new do
helper.group_title(nested_group)
end
expect do
helper.group_title(very_deep_nested_group)
end.not_to exceed_query_limit(control_count)
end
end
describe '#share_with_group_lock_help_text' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment