summaryrefslogtreecommitdiff
path: root/lib/api/v3
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-01-13 22:29:29 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-01-13 22:40:14 +0100
commitc9a1a1552a11a9ff862bf08df7267c553f2e0e99 (patch)
treec911d3e38b0d721e52ec34e4d442010874c36944 /lib/api/v3
parent7e0849840af4625c8ef37621f1ebc1696960be86 (diff)
downloadgitlab-ce-c9a1a1552a11a9ff862bf08df7267c553f2e0e99.tar.gz
Fix N+1 in v3 builds API
The N+1 issue was caused by loading the job_artifacts_archive for each job (build) individually. Including that in the builds AssociationRelation fixed the issue.
Diffstat (limited to 'lib/api/v3')
-rw-r--r--lib/api/v3/builds.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/api/v3/builds.rb b/lib/api/v3/builds.rb
index fa0bef39602..a256a5720e1 100644
--- a/lib/api/v3/builds.rb
+++ b/lib/api/v3/builds.rb
@@ -35,8 +35,7 @@ module API
get ':id/builds' do
builds = user_project.builds.order('id DESC')
builds = filter_builds(builds, params[:scope])
-
- present paginate(builds), with: ::API::V3::Entities::Build
+ present paginate(builds.includes(:job_artifacts_archive)), with: ::API::V3::Entities::Build
end
desc 'Get builds for a specific commit of a project' do