summaryrefslogtreecommitdiff
path: root/lib/api/v3/branches.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-06 13:29:17 +0100
committerRémy Coutable <remy@rymai.me>2017-11-06 13:31:23 +0100
commitb20984dea2fbbb20bc2807903115076b2a1de461 (patch)
treec8fa65db75e4b84b85ab70a34769dd08e69f310e /lib/api/v3/branches.rb
parentd77b9715406f027a060f376199dbd1f56dd866b3 (diff)
downloadgitlab-ce-b20984dea2fbbb20bc2807903115076b2a1de461.tar.gz
Improve performance of the /projects/:id/repository/branches API endpoint
Mitigate a N+1 requests to Gitaly problem. Still one left. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/api/v3/branches.rb')
-rw-r--r--lib/api/v3/branches.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/api/v3/branches.rb b/lib/api/v3/branches.rb
index 69cd12de72c..b201bf77667 100644
--- a/lib/api/v3/branches.rb
+++ b/lib/api/v3/branches.rb
@@ -14,9 +14,11 @@ module API
success ::API::Entities::Branch
end
get ":id/repository/branches" do
- branches = user_project.repository.branches.sort_by(&:name)
+ repository = user_project.repository
+ branches = repository.branches.sort_by(&:name)
+ merged_branch_names = repository.merged_branch_names(branches.map(&:name))
- present branches, with: ::API::Entities::Branch, project: user_project
+ present branches, with: ::API::Entities::Branch, project: user_project, merged_branch_names: merged_branch_names
end
desc 'Delete a branch'