diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-07-31 18:47:22 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-01 16:26:38 +0300 |
commit | fc4a0cd055643d6d66ed0dc8f0ba3ad5f09f6a95 (patch) | |
tree | 10edbe2ddaf174407f2867089f0cae14cac0f5fb /app | |
parent | abae261b86d8a1eedb50e85083cad1a07154c4d3 (diff) |
Only serializes diff files found by paths query
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request_diff.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index a073bbfad20..dbc072c19a9 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -249,15 +249,13 @@ class MergeRequestDiff < ActiveRecord::Base end def load_diffs(options) - raw = merge_request_diff_files.map(&:to_hash) + collection = merge_request_diff_files if paths = options[:paths] - raw = raw.select do |diff| - paths.include?(diff[:old_path]) || paths.include?(diff[:new_path]) - end + collection = collection.where('old_path IN (?) OR new_path IN (?)', paths, paths) end - Gitlab::Git::DiffCollection.new(raw, options) + Gitlab::Git::DiffCollection.new(collection.map(&:to_hash), options) end def load_commits |