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