diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-03-31 17:49:43 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-08 14:37:46 -0500 |
commit | 2c0de7aaafd5fb842618bb7fa218e11255363bc8 (patch) | |
tree | c2639eb9e055ae841821db9c9cad5b634a93bb4e /app/models/merge_request.rb | |
parent | b202b42cfee6bb8cf0c142c918c545f45464a29c (diff) | |
download | gitlab-ce-2c0de7aaafd5fb842618bb7fa218e11255363bc8.tar.gz |
Cache MR diffs by diff refs
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 1b6e898a7fd..95e41106b49 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -368,7 +368,11 @@ class MergeRequest < ActiveRecord::Base end def merge_request_diff_for(diff_refs) - merge_request_diffs.viewable.select_without_diff.with_diff_refs(diff_refs).take + @merge_request_diffs_by_diff_refs ||= Hash.new do |h, diff_refs| + h[diff_refs] = merge_request_diffs.viewable.select_without_diff.with_diff_refs(diff_refs).take + end + + @merge_request_diffs_by_diff_refs[diff_refs] end def reload_diff_if_branch_changed |