diff options
author | Rémy Coutable <remy@rymai.me> | 2018-03-28 16:16:33 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-28 16:16:33 +0000 |
commit | 141748929dd006e4b506028e44e7dfdf3988c936 (patch) | |
tree | 63d642060fb4f65a99a0d1ebf497ee37cceceea5 /app/controllers/projects | |
parent | be944a649032ccfa07f4f98cb2d048e14725fed1 (diff) | |
parent | 05b4b2d9679ccd09cf9723207603d0d3f670df30 (diff) | |
download | gitlab-ce-141748929dd006e4b506028e44e7dfdf3988c936.tar.gz |
Merge branch '44657-reuse-root_ref_hash-on-branches' into 'master'
Avoid Gitaly n+1 times per request for Project Branches performance
Closes #44657 et #37429
See merge request gitlab-org/gitlab-ce!17998
Diffstat (limited to 'app/controllers/projects')
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 965cece600e..176679f0849 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -21,17 +21,13 @@ class Projects::BranchesController < Projects::ApplicationController fetch_branches_by_mode @refs_pipelines = @project.pipelines.latest_successful_for_refs(@branches.map(&:name)) - @merged_branch_names = - repository.merged_branch_names(@branches.map(&:name)) - # n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37429 - Gitlab::GitalyClient.allow_n_plus_1_calls do - @max_commits = @branches.reduce(0) do |memo, branch| - diverging_commit_counts = repository.diverging_commit_counts(branch) - [memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max - end - - render + @merged_branch_names = repository.merged_branch_names(@branches.map(&:name)) + @max_commits = @branches.reduce(0) do |memo, branch| + diverging_commit_counts = repository.diverging_commit_counts(branch) + [memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max end + + render end format.json do branches = BranchesFinder.new(@repository, params).execute |