2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class NoteSummary
|
|
|
|
attr_reader :note
|
|
|
|
attr_reader :metadata
|
|
|
|
|
|
|
|
def initialize(noteable, project, author, body, action: nil, commit_count: nil)
|
2019-07-31 22:56:46 +05:30
|
|
|
@note = { noteable: noteable,
|
|
|
|
created_at: noteable.system_note_timestamp,
|
|
|
|
project: project, author: author, note: body }
|
2017-08-17 22:00:37 +05:30
|
|
|
@metadata = { action: action, commit_count: commit_count }.compact
|
|
|
|
|
|
|
|
set_commit_params if note[:noteable].is_a?(Commit)
|
|
|
|
end
|
|
|
|
|
|
|
|
def metadata?
|
|
|
|
metadata.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_commit_params
|
|
|
|
note.merge!(noteable_type: 'Commit', commit_id: note[:noteable].id)
|
|
|
|
note[:noteable] = nil
|
|
|
|
end
|
|
|
|
end
|