summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-30 15:32:09 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-03 14:47:21 -0500
commitf8fabfcc6ff6be4e20e3cc9353be86b7cf53af47 (patch)
tree15816b09ecdebbd4eb797195b90cb4f46b6819c4 /app/models/note.rb
parent185fd98fd4cb8f920558aea3795c4e1774cd39f5 (diff)
downloadgitlab-ce-f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47.tar.gz
Allow commenting on older versions of the diff and comparisons between diff versionsdm-link-discussion-to-outdated-diff
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb22
1 files changed, 13 insertions, 9 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index e720bfba030..b06985b4a6f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -115,11 +115,19 @@ class Note < ActiveRecord::Base
end
def grouped_diff_discussions(diff_refs = nil)
- diff_notes.
- fresh.
- discussions.
- select { |n| n.active?(diff_refs) }.
- group_by(&:line_code)
+ groups = {}
+
+ diff_notes.fresh.discussions.each do |discussion|
+ if discussion.active?(diff_refs)
+ discussions = groups[discussion.line_code] ||= []
+ elsif diff_refs && discussion.created_at_diff?(diff_refs)
+ discussions = groups[discussion.original_line_code] ||= []
+ end
+
+ discussions << discussion if discussions
+ end
+
+ groups
end
def count_for_collection(ids, type)
@@ -141,10 +149,6 @@ class Note < ActiveRecord::Base
true
end
- def latest_merge_request_diff
- nil
- end
-
def max_attachment_size
current_application_settings.max_attachment_size.megabytes.to_i
end