Commit 2495bbbd authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'sh-fix-rebase-in-progress-nplus-one' into 'master'

Memoize MergeRequest#rebase_in_progress? to prevent N+1 queries in Gitaly

Closes #4857

See merge request gitlab-org/gitlab-ee!4439
parents 14e21931 465d889e
...@@ -164,11 +164,13 @@ class MergeRequest < ActiveRecord::Base ...@@ -164,11 +164,13 @@ class MergeRequest < ActiveRecord::Base
end end
def rebase_in_progress? def rebase_in_progress?
strong_memoize(:rebase_in_progress) do
# The source project can be deleted # The source project can be deleted
return false unless source_project next false unless source_project
source_project.repository.rebase_in_progress?(id) source_project.repository.rebase_in_progress?(id)
end end
end
# Use this method whenever you need to make sure the head_pipeline is synced with the # Use this method whenever you need to make sure the head_pipeline is synced with the
# branch head commit, for example checking if a merge request can be merged. # branch head commit, for example checking if a merge request can be merged.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment