Commit de1db497 authored by Stan Hu's avatar Stan Hu

Avoidp loading merge request diff files when not needed

parent 0844ba04
......@@ -38,7 +38,7 @@ module MergeRequests
# reloading the diff.
MergeRequestDiff
.where(merge_request: merge_request)
.preload(:merge_request_diff_files, merge_request: :target_project)
.preload(merge_request: :target_project)
.find_each do |merge_request_diff|
next if merge_request_diff == new_diff
......
......@@ -17,7 +17,6 @@ module Gitlab
@diffable = diffable
@include_stats = diff_options.delete(:include_stats)
@diffs = diffable.raw_diffs(diff_options)
@project = project
@diff_options = diff_options
@diff_refs = diff_refs
......@@ -25,8 +24,12 @@ module Gitlab
@repository = project.repository
end
def diffs
@diffs ||= diffable.raw_diffs(diff_options)
end
def diff_files
@diff_files ||= @diffs.decorate! { |diff| decorate_diff!(diff) }
@diff_files ||= diffs.decorate! { |diff| decorate_diff!(diff) }
end
def diff_file_with_old_path(old_path)
......
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