diff options
author | Marin Jankovski <marin@gitlab.com> | 2018-02-08 14:00:21 +0300 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2018-02-08 17:49:25 +0300 |
commit | 1587e334992a6917970e37e763ed34c0fafd53a6 (patch) | |
tree | 1ea4dd3eb11bec11d08ad8d721df5f14ba360e3a | |
parent | 6ea755fa45406cf31ac8243354c1bb833b60b79b (diff) |
Merge branch 'sh-fix-rebase-in-progress-nplus-one' into 'master'
Memoize MergeRequest#rebase_in_progress? to prevent N+1 queries in Gitaly
Closes gitlab-ee#4857
See merge request gitlab-org/gitlab-ce!16990
-rw-r--r-- | app/models/merge_request.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index d025062f562..5bec68ce4f6 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -158,10 +158,12 @@ class MergeRequest < ActiveRecord::Base end def rebase_in_progress? - # The source project can be deleted - return false unless source_project + strong_memoize(:rebase_in_progress) do + # The source project can be deleted + next false unless source_project - source_project.repository.rebase_in_progress?(id) + source_project.repository.rebase_in_progress?(id) + end end # Use this method whenever you need to make sure the head_pipeline is synced with the |