diff options
Diffstat (limited to 'app/services/system_notes/issuables_service.rb')
-rw-r--r-- | app/services/system_notes/issuables_service.rb | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/app/services/system_notes/issuables_service.rb b/app/services/system_notes/issuables_service.rb index 7535db54130..2252503d97e 100644 --- a/app/services/system_notes/issuables_service.rb +++ b/app/services/system_notes/issuables_service.rb @@ -2,6 +2,34 @@ module SystemNotes class IssuablesService < ::SystemNotes::BaseService + # + # noteable_ref - Referenced noteable object + # + # Example Note text: + # + # "marked this issue as related to gitlab-foss#9001" + # + # Returns the created Note object + def relate_issue(noteable_ref) + body = "marked this issue as related to #{noteable_ref.to_reference(noteable.project)}" + + create_note(NoteSummary.new(noteable, project, author, body, action: 'relate')) + end + + # + # noteable_ref - Referenced noteable object + # + # Example Note text: + # + # "removed the relation with gitlab-foss#9001" + # + # Returns the created Note object + def unrelate_issue(noteable_ref) + body = "removed the relation with #{noteable_ref.to_reference(noteable.project)}" + + create_note(NoteSummary.new(noteable, project, author, body, action: 'unrelate')) + end + # Called when the assignee of a Noteable is changed or removed # # assignee - User being assigned, or nil @@ -16,6 +44,8 @@ module SystemNotes def change_assignee(assignee) body = assignee.nil? ? 'removed assignee' : "assigned to #{assignee.to_reference}" + issue_activity_counter.track_issue_assignee_changed_action(author: author) if noteable.is_a?(Issue) + create_note(NoteSummary.new(noteable, project, author, body, action: 'assignee')) end @@ -46,25 +76,9 @@ module SystemNotes body = text_parts.join(' and ') - create_note(NoteSummary.new(noteable, project, author, body, action: 'assignee')) - end - - # Called when the milestone of a Noteable is changed - # - # milestone - Milestone being assigned, or nil - # - # Example Note text: - # - # "removed milestone" - # - # "changed milestone to 7.11" - # - # Returns the created Note object - def change_milestone(milestone) - format = milestone&.group_milestone? ? :name : :iid - body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}" + issue_activity_counter.track_issue_assignee_changed_action(author: author) if noteable.is_a?(Issue) - create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) + create_note(NoteSummary.new(noteable, project, author, body, action: 'assignee')) end # Called when the title of a Noteable is changed @@ -86,6 +100,8 @@ module SystemNotes body = "changed title from **#{marked_old_title}** to **#{marked_new_title}**" + issue_activity_counter.track_issue_title_changed_action(author: author) if noteable.is_a?(Issue) + create_note(NoteSummary.new(noteable, project, author, body, action: 'title')) end @@ -103,6 +119,8 @@ module SystemNotes def change_description body = 'changed the description' + issue_activity_counter.track_issue_description_changed_action(author: author) if noteable.is_a?(Issue) + create_note(NoteSummary.new(noteable, project, author, body, action: 'description')) end @@ -199,9 +217,13 @@ module SystemNotes if noteable.confidential body = 'made the issue confidential' action = 'confidential' + + issue_activity_counter.track_issue_made_confidential_action(author: author) if noteable.is_a?(Issue) else body = 'made the issue visible to everyone' action = 'visible' + + issue_activity_counter.track_issue_made_visible_action(author: author) if noteable.is_a?(Issue) end create_note(NoteSummary.new(noteable, project, author, body, action: action)) @@ -343,6 +365,10 @@ module SystemNotes noteable.respond_to?(:resource_state_events) && ::Feature.enabled?(:track_resource_state_change_events, noteable.project, default_enabled: true) end + + def issue_activity_counter + Gitlab::UsageDataCounters::IssueActivityUniqueCounter + end end end |