diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2017-09-19 10:55:37 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-19 10:55:37 +0000 |
commit | 64d7ec0a9e3ffd6233ccfbe9100f8a9391c648e5 (patch) | |
tree | 2cc89bc2d1087eb145918c6ae8cbf70878d40e97 /app/controllers/projects/branches_controller.rb | |
parent | 39dd7736585d3e35d5c6f391e6a94c312da09056 (diff) | |
download | gitlab-ce-64d7ec0a9e3ffd6233ccfbe9100f8a9391c648e5.tar.gz |
Detect n+1 issues involving Gitaly
Diffstat (limited to 'app/controllers/projects/branches_controller.rb')
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 747768eefb1..a9cce578366 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -15,10 +15,14 @@ class Projects::BranchesController < Projects::ApplicationController respond_to do |format| format.html do @refs_pipelines = @project.pipelines.latest_successful_for_refs(@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 - @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 + render end end format.json do |