Commit fffdd5c4 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '326212-controller-projects-hookscontroller-index-executes-more-than-100-sql-queries' into 'master'

Avoid N+1 queries in breadcrumbs

See merge request gitlab-org/gitlab!57725
parents d71b2196 d5f2b32a
...@@ -121,7 +121,9 @@ module GroupsHelper ...@@ -121,7 +121,9 @@ module GroupsHelper
@has_group_title = true @has_group_title = true
full_title = [] 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 if index > 0
add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before) add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before)
else else
......
---
title: Avoid N+1 queries in breadcrumbs
merge_request: 57725
author:
type: performance
...@@ -109,6 +109,16 @@ RSpec.describe GroupsHelper do ...@@ -109,6 +109,16 @@ RSpec.describe GroupsHelper do
subject subject
end 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 end
describe '#share_with_group_lock_help_text' do 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