summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-03-05 15:49:24 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-03-05 15:49:24 -0300
commit6d4d02a7578fb6e60f33388534d1e4c5fcdbf7b5 (patch)
treef0260aa9fcc84a6dcf1ae240b687b548031fa4b4
parent2a5794a3297f7e3d8b07fbd8037978ae57268945 (diff)
downloadgitlab-ce-banzai-n-plus-one.tar.gz
Prevent unnecesary calls to Banzai processing on CompareController#showbanzai-n-plus-one
-rw-r--r--app/controllers/projects/compare_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 2b0c2ca97c0..231f2df8201 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -10,6 +10,7 @@ class Projects::CompareController < Projects::ApplicationController
before_action :authorize_download_code!
before_action :define_ref_vars, only: [:index, :show, :diff_for_path]
before_action :define_diff_vars, only: [:show, :diff_for_path]
+ before_action :prepare_commits, only: [:diff_for_path]
before_action :merge_request, only: [:index, :show]
def index
@@ -53,7 +54,7 @@ class Projects::CompareController < Projects::ApplicationController
.execute(@project, @start_ref)
if @compare
- @commits = prepare_commits_for_rendering(@compare.commits)
+ @commits = @compare.commits
@diffs = @compare.diffs(diff_options)
environment_params = @repository.branch_exists?(@head_ref) ? { ref: @head_ref } : { commit: @compare.commit }
@@ -63,6 +64,10 @@ class Projects::CompareController < Projects::ApplicationController
end
end
+ def prepare_commits
+ @commits = prepare_commits_for_rendering(@commits)
+ end
+
def merge_request
@merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
.find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref)