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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
6f4a0a92
Commit
6f4a0a92
authored
Jun 03, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate N+1 queries with authors and push_data_payload in Events API
parent
5426f09f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
changelogs/unreleased/sh-fix-events-nplus-one.yml
changelogs/unreleased/sh-fix-events-nplus-one.yml
+5
-0
lib/api/events.rb
lib/api/events.rb
+1
-0
spec/requests/api/events_spec.rb
spec/requests/api/events_spec.rb
+2
-2
No files found.
changelogs/unreleased/sh-fix-events-nplus-one.yml
0 → 100644
View file @
6f4a0a92
---
title
:
Eliminate N+1 queries with authors and push_data_payload in Events API
merge_request
:
author
:
type
:
performance
lib/api/events.rb
View file @
6f4a0a92
...
...
@@ -17,6 +17,7 @@ module API
def
present_events
(
events
)
events
=
events
.
reorder
(
created_at:
params
[
:sort
])
.
with_associations
present
paginate
(
events
),
with:
Entities
::
Event
end
...
...
spec/requests/api/events_spec.rb
View file @
6f4a0a92
...
...
@@ -176,7 +176,7 @@ describe API::Events do
end
it
'avoids N+1 queries'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
),
target_type: :merge_request
end
.
count
...
...
@@ -184,7 +184,7 @@ describe API::Events do
expect
do
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
),
target_type: :merge_request
end
.
not_to
exceed_query_limit
(
control_count
)
end
.
not_to
exceed_
all_
query_limit
(
control_count
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
...
...
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