diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/services/system_notes | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/services/system_notes')
-rw-r--r-- | app/services/system_notes/alert_management_service.rb | 15 | ||||
-rw-r--r-- | app/services/system_notes/issuables_service.rb | 62 |
2 files changed, 59 insertions, 18 deletions
diff --git a/app/services/system_notes/alert_management_service.rb b/app/services/system_notes/alert_management_service.rb index f835376727a..376f2c1cfbf 100644 --- a/app/services/system_notes/alert_management_service.rb +++ b/app/services/system_notes/alert_management_service.rb @@ -2,6 +2,21 @@ module SystemNotes class AlertManagementService < ::SystemNotes::BaseService + # Called when the a new AlertManagement::Alert has been created + # + # alert - AlertManagement::Alert object. + # + # Example Note text: + # + # "GitLab Alert Bot logged an alert from Prometheus" + # + # Returns the created Note object + def create_new_alert(monitoring_tool) + body = "logged an alert from **#{monitoring_tool}**" + + create_note(NoteSummary.new(noteable, project, User.alert_bot, body, action: 'new_alert_added')) + end + # Called when the status of an AlertManagement::Alert has changed # # alert - AlertManagement::Alert object. 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 |