Commit d9a949c1 authored by Douwe Maan's avatar Douwe Maan

Use correct user for 'Discussion resolved by...'

parent 1bee660b
...@@ -21,7 +21,8 @@ class Discussion ...@@ -21,7 +21,8 @@ class Discussion
delegate :resolved_at, delegate :resolved_at,
:resolved_by, :resolved_by,
to: :last_note to: :last_resolved_note,
allow_nil: true
delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true
...@@ -39,6 +40,12 @@ class Discussion ...@@ -39,6 +40,12 @@ class Discussion
@notes = notes @notes = notes
end end
def last_resolved_note
return unless resolved?
@last_resolved_note ||= resolved_notes.sort_by(&:resolved_at).last
end
def last_updated_at def last_updated_at
last_note.created_at last_note.created_at
end end
...@@ -67,6 +74,10 @@ class Discussion ...@@ -67,6 +74,10 @@ class Discussion
resolvable? && notes.none?(&:to_be_resolved?) resolvable? && notes.none?(&:to_be_resolved?)
end end
def resolved_notes
notes.select(&:resolved?)
end
def to_be_resolved? def to_be_resolved?
notes.any?(&:to_be_resolved?) notes.any?(&:to_be_resolved?)
end end
......
...@@ -395,15 +395,18 @@ class MergeRequest < ActiveRecord::Base ...@@ -395,15 +395,18 @@ class MergeRequest < ActiveRecord::Base
end end
def discussions def discussions
self.mr_and_commit_notes. @discussions ||= self.mr_and_commit_notes.
inc_author_project_award_emoji. inc_author_project_award_emoji.
fresh. fresh.
discussions discussions
end end
def discussions_resolvable?
discussions.any?(&:resolvable?)
end
def discussions_resolved? def discussions_resolved?
all_discussions = discussions discussions_resolvable? && discussions.none?(&:to_be_resolved?)
all_discussions.any?(&:resolvable?) && all_discussions.none?(&:to_be_resolved?)
end end
def hook_attrs def hook_attrs
......
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