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
134bba44
Commit
134bba44
authored
Apr 07, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix N+1 in REST projects and service desk
parent
ba77e7d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
changelogs/unreleased/21121-fj-fix-n-1-in-projects-and-service-desk.yml
...eleased/21121-fj-fix-n-1-in-projects-and-service-desk.yml
+5
-0
lib/api/entities/project.rb
lib/api/entities/project.rb
+1
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+23
-0
No files found.
changelogs/unreleased/21121-fj-fix-n-1-in-projects-and-service-desk.yml
0 → 100644
View file @
134bba44
---
title
:
Fix N+1 in REST projects and service desk
merge_request
:
58747
author
:
type
:
performance
lib/api/entities/project.rb
View file @
134bba44
...
...
@@ -132,6 +132,7 @@ module API
.
preload
(
:project_setting
)
.
preload
(
:container_expiration_policy
)
.
preload
(
:auto_devops
)
.
preload
(
:service_desk_setting
)
.
preload
(
project_group_links:
{
group: :route
},
fork_network: :root_project
,
fork_network_member: :forked_from_project
,
...
...
spec/requests/api/projects_spec.rb
View file @
134bba44
...
...
@@ -835,6 +835,29 @@ RSpec.describe API::Projects do
end
.
not_to
exceed_query_limit
(
control
.
count
)
end
end
context
'when service desk is enabled'
,
:use_clean_rails_memory_store_caching
do
let_it_be
(
:admin
)
{
create
(
:admin
)
}
it
'avoids N+1 queries'
do
allow
(
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:enabled?
).
and_return
(
true
)
allow
(
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
).
and_return
(
true
)
get
api
(
'/projects'
,
admin
)
create
(
:project
,
:public
,
:service_desk_enabled
,
namespace:
admin
.
namespace
)
control
=
ActiveRecord
::
QueryRecorder
.
new
do
get
api
(
'/projects'
,
admin
)
end
create_list
(
:project
,
2
,
:public
,
:service_desk_enabled
,
namespace:
admin
.
namespace
)
expect
do
get
api
(
'/projects'
,
admin
)
end
.
not_to
exceed_query_limit
(
control
.
count
)
end
end
end
describe
'POST /projects'
do
...
...
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