Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ace04aee
Commit
ace04aee
authored
Jul 10, 2020
by
Dmitry Gruzd
Committed by
Dylan Griffith
Jul 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve remaining N+1 in Search API (Advanced) projects scope
parent
6566448f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
6 deletions
+18
-6
app/models/namespace.rb
app/models/namespace.rb
+2
-0
app/models/project.rb
app/models/project.rb
+1
-1
changelogs/unreleased/218703-fix-api-projects-search-n-plus-1.yml
...gs/unreleased/218703-fix-api-projects-search-n-plus-1.yml
+5
-0
ee/spec/lib/gitlab/auth/group_saml/gma_membership_enforcer_spec.rb
...ib/gitlab/auth/group_saml/gma_membership_enforcer_spec.rb
+4
-4
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+6
-1
No files found.
app/models/namespace.rb
View file @
ace04aee
...
...
@@ -287,6 +287,8 @@ class Namespace < ApplicationRecord
end
def
root_ancestor
return
self
if
persisted?
&&
parent_id
.
nil?
strong_memoize
(
:root_ancestor
)
do
self_and_ancestors
.
reorder
(
nil
).
find_by
(
parent_id:
nil
)
end
...
...
app/models/project.rb
View file @
ace04aee
...
...
@@ -524,7 +524,7 @@ class Project < ApplicationRecord
scope
:with_api_entity_associations
,
->
{
preload
(
:project_feature
,
:route
,
:tags
,
group:
:ip_restrictions
,
namespace:
[
:route
,
:owner
])
group:
[
:ip_restrictions
,
:saml_provider
]
,
namespace:
[
:route
,
:owner
])
}
scope
:with_api_commit_entity_associations
,
->
{
...
...
changelogs/unreleased/218703-fix-api-projects-search-n-plus-1.yml
0 → 100644
View file @
ace04aee
---
title
:
Resolve N+1 in Search API projects scope
merge_request
:
35833
author
:
type
:
performance
ee/spec/lib/gitlab/auth/group_saml/gma_membership_enforcer_spec.rb
View file @
ace04aee
...
...
@@ -5,10 +5,10 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Auth
::
GroupSaml
::
GmaMembershipEnforcer
do
include
ProjectForksHelper
let
_it_be
(
:group
)
{
create
(
:group_with_managed_accounts
,
:private
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
namespace:
group
)}
let
_it_be
(
:managed_user
)
{
create
(
:user
,
:group_managed
,
managing_group:
group
)
}
let
_it_be
(
:managed_user_for_project
)
{
create
(
:user
,
:group_managed
,
managing_group:
group
)
}
let
(
:group
)
{
create
(
:group_with_managed_accounts
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)}
let
(
:managed_user
)
{
create
(
:user
,
:group_managed
,
managing_group:
group
)
}
let
(
:managed_user_for_project
)
{
create
(
:user
,
:group_managed
,
managing_group:
group
)
}
subject
{
described_class
.
new
(
project
)
}
...
...
spec/models/namespace_spec.rb
View file @
ace04aee
...
...
@@ -884,8 +884,13 @@ RSpec.describe Namespace do
end
describe
'#root_ancestor'
do
let!
(
:root_group
)
{
create
(
:group
)
}
it
'returns root_ancestor for root group without a query'
do
expect
{
root_group
.
root_ancestor
}.
not_to
exceed_query_limit
(
0
)
end
it
'returns the top most ancestor'
do
root_group
=
create
(
:group
)
nested_group
=
create
(
:group
,
parent:
root_group
)
deep_nested_group
=
create
(
:group
,
parent:
nested_group
)
very_deep_nested_group
=
create
(
:group
,
parent:
deep_nested_group
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment