diff options
author | Stan Hu <stanhu@gmail.com> | 2018-01-16 19:56:05 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-01-16 19:56:05 +0300 |
commit | 191b5153c86964e59400fe086b88b89bb45fe7a9 (patch) | |
tree | aa4658dd7feb64caa9519d4d7480ebc4e7b8969b /lib | |
parent | 79b05cdd469726582e916cb606ba14b440a59011 (diff) | |
parent | feb3449709ce4fce62227f67233bc4d061c66ab5 (diff) |
Merge branch 'builds-api-nplusone' into 'master'
Resolve "N+1 queries with /projects/:project_id/builds API endpoint"
Closes #41957
See merge request gitlab-org/gitlab-ce!16445
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/jobs.rb | 1 | ||||
-rw-r--r-- | lib/api/v3/builds.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb index a116ab3c9bd..9c205514b3a 100644 --- a/lib/api/jobs.rb +++ b/lib/api/jobs.rb @@ -38,6 +38,7 @@ module API builds = user_project.builds.order('id DESC') builds = filter_builds(builds, params[:scope]) + builds = builds.preload(:user, :job_artifacts_archive, :runner, pipeline: :project) present paginate(builds), with: Entities::Job end diff --git a/lib/api/v3/builds.rb b/lib/api/v3/builds.rb index fa0bef39602..ac76fece931 100644 --- a/lib/api/v3/builds.rb +++ b/lib/api/v3/builds.rb @@ -36,6 +36,7 @@ module API builds = user_project.builds.order('id DESC') builds = filter_builds(builds, params[:scope]) + builds = builds.preload(:user, :job_artifacts_archive, :runner, pipeline: :project) present paginate(builds), with: ::API::V3::Entities::Build end |