summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-08-02 09:01:02 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-08-02 09:01:02 +0000
commit2deb97adff1414d469e31ffad8582ab3c65bb80f (patch)
tree9cec6bfc0c08fa029ea46dc6dd99ec49dd6acbb7 /app
parent0233fffe283857d9934460625f9c17fcd278536b (diff)
parentfc4a0cd055643d6d66ed0dc8f0ba3ad5f09f6a95 (diff)
downloadgitlab-ce-2deb97adff1414d469e31ffad8582ab3c65bb80f.tar.gz
Merge branch '48246-osw-load-diffs-improvement' into 'master'
Filter diff files by given path on DB instead Ruby See merge request gitlab-org/gitlab-ce!20940
Diffstat (limited to 'app')
-rw-r--r--app/models/merge_request_diff.rb8
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