summaryrefslogtreecommitdiff
path: root/app/models/diff_note.rb
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2019-09-06 18:19:48 -0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2019-09-10 20:33:46 -0300
commitf66c00adc6d475162b14eed29290923e9ea8a25f (patch)
tree4818d002b22ec95272458e03a1ebb93df812e68f /app/models/diff_note.rb
parent0402fc13d2bca3e483a36676c6c11157b5863cd7 (diff)
downloadgitlab-ce-osw-improve-discussions-query.tar.gz
Improve the performance for MR discussions loadosw-improve-discussions-query
It considerably improves the query for preloading MR discussion diffs for: 1. MR diff comments (made at Diffs tab; presented at the main MR page) 2. Comments on commits being listed at the MR Additionally, it also prevents a second similar query that was unnecessarily being made.
Diffstat (limited to 'app/models/diff_note.rb')
-rw-r--r--app/models/diff_note.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index 861185dc222..bae442481af 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -108,13 +108,10 @@ class DiffNote < Note
end
def fetch_diff_file
+ return note_diff_file.raw_diff_file if note_diff_file
+
file =
- if note_diff_file
- diff = Gitlab::Git::Diff.new(note_diff_file.to_hash)
- Gitlab::Diff::File.new(diff,
- repository: repository,
- diff_refs: original_position.diff_refs)
- elsif created_at_diff?(noteable.diff_refs)
+ if created_at_diff?(noteable.diff_refs)
# We're able to use the already persisted diffs (Postgres) if we're
# presenting a "current version" of the MR discussion diff.
# So no need to make an extra Gitaly diff request for it.
@@ -126,9 +123,7 @@ class DiffNote < Note
original_position.diff_file(repository)
end
- # Since persisted diff files already have its content "unfolded"
- # there's no need to make it pass through the unfolding process.
- file&.unfold_diff_lines(position) unless note_diff_file
+ file&.unfold_diff_lines(position)
file
end