Commit 14843d0a authored by Michael Kozono's avatar Michael Kozono

Merge branch 'issue_292253-issue_removed_from_epic' into 'master'

Track issue removed from epic

See merge request gitlab-org/gitlab!58426
parents 6b494631 7a10b532
......@@ -15,14 +15,18 @@ module IssuableLinks
return error(not_found_message, 404) unless permission_to_remove_relation?
remove_relation
create_notes
track_event
after_destroy
success(message: 'Relation was removed')
end
private
def after_destroy
create_notes
track_event
end
def remove_relation
link.destroy!
end
......
......@@ -9908,6 +9908,30 @@ Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_monthly`
Count of MAU removing issues from epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210401183230_g_project_management_epic_issue_removed_monthly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_weekly`
Counts of WAU removing issues from epics
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210401182457_g_project_management_g_project_management_epic_issue_removed_weekly.yml)
Group: `group::product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_epic_reopened_monthly`
Counts of MAU closing epics
......
......@@ -2,14 +2,21 @@
module EpicIssues
class DestroyService < IssuableLinks::DestroyService
def execute
result = super
Epics::UpdateDatesService.new([link.epic]).execute
extend ::Gitlab::Utils::Override
private
override :after_destroy
def after_destroy
super
result
Epics::UpdateDatesService.new([link.epic]).execute
track_usage_ping_event
end
private
def track_usage_ping_event
::Gitlab::UsageDataCounters::EpicActivityUniqueCounter.track_epic_issue_removed(author: current_user)
end
def source
@source ||= link.epic
......
---
title: Track issue removed from epic on usage ping
merge_request: 58426
author:
type: other
---
# Name of this metric contains g_project_management prefix
# because we are using the same slot from issue_tracking to
# allow data aggregation.
key_path: redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_monthly
description: Count of MAU removing issues from epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58426
time_frame: 28d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
---
# Name of this metric contains g_project_management prefix
# because we are using the same slot from issue_tracking to
# allow data aggregation.
key_path: redis_hll_counters.epics_usage.g_project_management_epic_issue_removed_weekly
description: Counts of WAU removing issues from epics
product_section: dev
product_stage: plan
product_group: group::product planning
product_category: epics_usage
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58426
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
......@@ -20,6 +20,7 @@ module Gitlab
EPIC_FIXED_START_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_start_date'
EPIC_FIXED_DUE_DATE_UPDATED = 'g_project_management_users_updating_fixed_epic_due_date'
EPIC_ISSUE_ADDED = 'g_project_management_epic_issue_added'
EPIC_ISSUE_REMOVED = 'g_project_management_epic_issue_removed'
EPIC_CLOSED = 'g_project_management_epic_closed'
EPIC_REOPENED = 'g_project_management_epic_reopened'
ISSUE_PROMOTED_TO_EPIC = 'g_project_management_issue_promoted_to_epic'
......@@ -79,6 +80,10 @@ module Gitlab
track_unique_action(EPIC_ISSUE_ADDED, author)
end
def track_epic_issue_removed(author:)
track_unique_action(EPIC_ISSUE_REMOVED, author)
end
def track_epic_closed_action(author:)
track_unique_action(EPIC_CLOSED, author)
end
......
......@@ -212,6 +212,18 @@ RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitl
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for removing issue from epic event' do
def track_action(params)
described_class.track_epic_issue_removed(**params)
end
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::EPIC_ISSUE_REMOVED }
end
it_behaves_like 'does not track when feature flag is disabled', :track_epics_activity
end
context 'for promoting issue to epic' do
def track_action(params)
described_class.track_issue_promoted_to_epic(**params)
......
......@@ -66,6 +66,13 @@ RSpec.describe EpicIssues::DestroyService do
expect(note.noteable_type).to eq('Issue')
expect(note.system_note_metadata.action).to eq('issue_removed_from_epic')
end
it 'counts an usage ping event' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_issue_removed)
.with(author: user)
subject
end
end
context 'user does not have permissions to remove associations' do
......@@ -76,10 +83,18 @@ RSpec.describe EpicIssues::DestroyService do
it 'returns error message' do
is_expected.to eq(message: 'No Issue Link found', status: :error, http_status: 404)
end
it 'does not counts an usage ping event' do
expect(::Gitlab::UsageDataCounters::EpicActivityUniqueCounter).not_to receive(:track_epic_issue_removed)
subject
end
end
context 'refresh epic dates' do
it 'calls UpdateDatesService' do
group.add_reporter(user)
expect(Epics::UpdateDatesService).to receive(:new).with([epic_issue.epic]).and_call_original
subject
......
......@@ -87,6 +87,12 @@
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_epic_issue_removed
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_epic_closed
category: epics_usage
redis_slot: project_management
......
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