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
e828e835
Commit
e828e835
authored
May 17, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoids N + 1 queries
parent
94f7595b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
lib/api/pipeline_schedules.rb
lib/api/pipeline_schedules.rb
+1
-1
spec/requests/api/pipeline_schedules_spec.rb
spec/requests/api/pipeline_schedules_spec.rb
+12
-0
No files found.
lib/api/pipeline_schedules.rb
View file @
e828e835
...
@@ -17,7 +17,7 @@ module API
...
@@ -17,7 +17,7 @@ module API
get
':id/pipeline_schedules'
do
get
':id/pipeline_schedules'
do
authorize!
:read_pipeline_schedule
,
user_project
authorize!
:read_pipeline_schedule
,
user_project
pipeline_schedules
=
user_project
.
pipeline_schedules
pipeline_schedules
=
user_project
.
pipeline_schedules
.
preload
(
:pipelines
)
present
paginate
(
pipeline_schedules
),
with:
Entities
::
PipelineSchedule
present
paginate
(
pipeline_schedules
),
with:
Entities
::
PipelineSchedule
end
end
...
...
spec/requests/api/pipeline_schedules_spec.rb
View file @
e828e835
...
@@ -25,6 +25,18 @@ describe API::PipelineSchedules do
...
@@ -25,6 +25,18 @@ describe API::PipelineSchedules do
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
match_response_schema
(
'pipeline_schedules'
)
expect
(
response
).
to
match_response_schema
(
'pipeline_schedules'
)
end
end
it
'avoids N + 1 queries'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
get
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
)
end
.
count
create_list
(
:ci_pipeline_schedule
,
10
,
project:
project
,
owner:
developer
)
expect
do
get
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
)
end
.
not_to
exceed_query_limit
(
control_count
)
end
end
end
context
'authenticated user with invalid permissions'
do
context
'authenticated user with invalid permissions'
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