Commit 5069bb02 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '292830-track-task-list-status-changes' into 'master'

Track task list status changed in MR description [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!53684
parents cd5b7498 714d7ad0
......@@ -258,6 +258,11 @@ class IssuableBaseService < BaseService
invalidate_cache_counts(issuable, users: issuable.assignees.to_a)
after_update(issuable)
execute_hooks(issuable, 'update', old_associations: nil)
if issuable.is_a?(MergeRequest)
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter
.track_task_item_status_changed(user: current_user)
end
end
end
......
---
name: usage_data_i_code_review_user_toggled_task_item_status
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/320851
rollout_issue_url:
milestone: '13.9'
type: development
group: group::code review
default_enabled: true
......@@ -14,6 +14,11 @@
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_mr_single_file_diffs
- name: i_code_review_user_toggled_task_item_status
redis_slot: code_review
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_toggled_task_item_status
- name: i_code_review_user_create_mr
redis_slot: code_review
category: code_review
......
......@@ -28,6 +28,7 @@ module Gitlab
MR_UNRESOLVE_THREAD_ACTION = 'i_code_review_user_unresolve_thread'
MR_ASSIGNED_USERS_ACTION = 'i_code_review_user_assigned'
MR_REVIEW_REQUESTED_USERS_ACTION = 'i_code_review_user_review_requested'
MR_TASK_ITEM_STATUS_CHANGED_ACTION = 'i_code_review_user_toggled_task_item_status'
MR_APPROVAL_RULE_ADDED_USERS_ACTION = 'i_code_review_user_approval_rule_added'
MR_APPROVAL_RULE_EDITED_USERS_ACTION = 'i_code_review_user_approval_rule_edited'
MR_APPROVAL_RULE_DELETED_USERS_ACTION = 'i_code_review_user_approval_rule_deleted'
......@@ -143,6 +144,10 @@ module Gitlab
track_unique_action_by_user(MR_APPROVAL_RULE_DELETED_USERS_ACTION, user)
end
def track_task_item_status_changed(user:)
track_unique_action_by_user(MR_TASK_ITEM_STATUS_CHANGED_ACTION, user)
end
private
def track_unique_action_by_merge_request(action, merge_request)
......
......@@ -237,6 +237,14 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl
end
end
describe '.track_task_item_status_changed' do
subject { described_class.track_task_item_status_changed(user: user) }
it_behaves_like 'a tracked merge request unique event' do
let(:action) { described_class::MR_TASK_ITEM_STATUS_CHANGED_ACTION }
end
end
describe '.track_users_review_requested' do
subject { described_class.track_users_review_requested(users: [user]) }
......
......@@ -18,6 +18,27 @@ RSpec.shared_examples 'updating a single task' do
update_issuable(description: "- [ ] Task 1\n- [ ] Task 2")
end
context 'usage counters' do
it 'update as expected' do
if try(:merge_request)
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_task_item_status_changed).once.with(user: user)
else
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.not_to receive(:track_task_item_status_changed)
end
update_issuable(
update_task: {
index: 1,
checked: true,
line_source: '- [ ] Task 1',
line_number: 1
}
)
end
end
context 'when a task is marked as completed' do
before do
update_issuable(update_task: { index: 1, checked: true, line_source: '- [ ] Task 1', line_number: 1 })
......
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