diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-05-31 18:12:27 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-06-01 12:51:53 -0300 |
commit | 80396341570ddae6e06361d9983acdd4bb4f0b85 (patch) | |
tree | 244d7cc6ca9d7866c314776fe76294b8da9d81a4 /app/models/note.rb | |
parent | aff097e8f528ab5b00842df7c76d3435b1e59c96 (diff) | |
download | gitlab-ce-issue_27166.tar.gz |
Remove repeated query for merge requests discussion collectionissue_27166
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 832c68243fb..115a2775ffb 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -249,7 +249,7 @@ class Note < ActiveRecord::Base # When commit notes are rendered on an MR's Discussion page, they are # displayed in one discussion instead of individually. # See also `#discussion_id` and `Discussion.override_discussion_id`. - if noteable && noteable != self.noteable + if different_context?(noteable) OutOfContextDiscussion else IndividualNoteDiscussion @@ -300,6 +300,12 @@ class Note < ActiveRecord::Base private + def different_context?(noteable) + return false unless noteable + + noteable.id != noteable_id && noteable.class.name != noteable_type + end + def keep_around_commit project.repository.keep_around(self.commit_id) end |