Commit febad03e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '325535-make-param-optional' into 'master'

Remove time param in Gitlab::UsageDataCounters::EpicActivityUniqueCounter

See merge request gitlab-org/gitlab!57114
parents c7a74884 d3d90022
......@@ -14,28 +14,28 @@ module EE
ISSUE_CHANGED_EPIC = 'g_project_management_issue_changed_epic'
class_methods do
def track_issue_health_status_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_HEALTH_STATUS_CHANGED, author, time)
def track_issue_health_status_changed_action(author:)
track_unique_action(ISSUE_HEALTH_STATUS_CHANGED, author)
end
def track_issue_iteration_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_ITERATION_CHANGED, author, time)
def track_issue_iteration_changed_action(author:)
track_unique_action(ISSUE_ITERATION_CHANGED, author)
end
def track_issue_weight_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_WEIGHT_CHANGED, author, time)
def track_issue_weight_changed_action(author:)
track_unique_action(ISSUE_WEIGHT_CHANGED, author)
end
def track_issue_added_to_epic_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_ADDED_TO_EPIC, author, time)
def track_issue_added_to_epic_action(author:)
track_unique_action(ISSUE_ADDED_TO_EPIC, author)
end
def track_issue_removed_from_epic_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_REMOVED_FROM_EPIC, author, time)
def track_issue_removed_from_epic_action(author:)
track_unique_action(ISSUE_REMOVED_FROM_EPIC, author)
end
def track_issue_changed_epic_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CHANGED_EPIC, author, time)
def track_issue_changed_epic_action(author:)
track_unique_action(ISSUE_CHANGED_EPIC, author)
end
end
end
......
......@@ -22,65 +22,65 @@ module Gitlab
EPIC_REOPENED = 'g_project_management_epic_reopened'
class << self
def track_epic_created_action(author:, time: Time.zone.now)
track_unique_action(EPIC_CREATED, author, time)
def track_epic_created_action(author:)
track_unique_action(EPIC_CREATED, author)
end
def track_epic_title_changed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_TITLE_CHANGED, author, time)
def track_epic_title_changed_action(author:)
track_unique_action(EPIC_TITLE_CHANGED, author)
end
def track_epic_description_changed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_DESCRIPTION_CHANGED, author, time)
def track_epic_description_changed_action(author:)
track_unique_action(EPIC_DESCRIPTION_CHANGED, author)
end
def track_epic_note_created_action(author:, time: Time.zone.now)
track_unique_action(EPIC_NOTE_CREATED, author, time)
def track_epic_note_created_action(author:)
track_unique_action(EPIC_NOTE_CREATED, author)
end
def track_epic_note_updated_action(author:, time: Time.zone.now)
track_unique_action(EPIC_NOTE_UPDATED, author, time)
def track_epic_note_updated_action(author:)
track_unique_action(EPIC_NOTE_UPDATED, author)
end
def track_epic_note_destroyed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_NOTE_DESTROYED, author, time)
def track_epic_note_destroyed_action(author:)
track_unique_action(EPIC_NOTE_DESTROYED, author)
end
def track_epic_start_date_set_as_fixed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_START_DATE_SET_AS_FIXED, author, time)
def track_epic_start_date_set_as_fixed_action(author:)
track_unique_action(EPIC_START_DATE_SET_AS_FIXED, author)
end
def track_epic_start_date_set_as_inherited_action(author:, time: Time.zone.now)
track_unique_action(EPIC_START_DATE_SET_AS_INHERITED, author, time)
def track_epic_start_date_set_as_inherited_action(author:)
track_unique_action(EPIC_START_DATE_SET_AS_INHERITED, author)
end
def track_epic_due_date_set_as_fixed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_DUE_DATE_SET_AS_FIXED, author, time)
def track_epic_due_date_set_as_fixed_action(author:)
track_unique_action(EPIC_DUE_DATE_SET_AS_FIXED, author)
end
def track_epic_due_date_set_as_inherited_action(author:, time: Time.zone.now)
track_unique_action(EPIC_DUE_DATE_SET_AS_INHERITED, author, time)
def track_epic_due_date_set_as_inherited_action(author:)
track_unique_action(EPIC_DUE_DATE_SET_AS_INHERITED, author)
end
def track_epic_issue_added(author:, time: Time.zone.now)
track_unique_action(EPIC_ISSUE_ADDED, author, time)
def track_epic_issue_added(author:)
track_unique_action(EPIC_ISSUE_ADDED, author)
end
def track_epic_closed_action(author:, time: Time.zone.now)
track_unique_action(EPIC_CLOSED, author, time)
def track_epic_closed_action(author:)
track_unique_action(EPIC_CLOSED, author)
end
def track_epic_reopened_action(author:, time: Time.zone.now)
track_unique_action(EPIC_REOPENED, author, time)
def track_epic_reopened_action(author:)
track_unique_action(EPIC_REOPENED, author)
end
private
def track_unique_action(action, author, time)
def track_unique_action(action, author)
return unless Feature.enabled?(:track_epics_activity, default_enabled: true)
return unless author
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id, time: time)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id)
end
end
end
......
......@@ -3,10 +3,8 @@
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_gitlab_redis_shared_state do
let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) }
let(:time) { Time.zone.now }
let_it_be(:user1) { build(:user, id: 1) }
let_it_be(:user2) { build(:user, id: 2) }
context 'for Issue health status changed actions' do
it_behaves_like 'a daily tracked issuable event' do
......
......@@ -3,10 +3,8 @@
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::EpicActivityUniqueCounter, :clean_gitlab_redis_shared_state do
let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) }
let(:time) { Time.zone.now }
let_it_be(:user1) { build(:user, id: 1) }
let_it_be(:user2) { build(:user, id: 2) }
context 'for epic created event' do
def track_action(params)
......
......@@ -34,120 +34,120 @@ module Gitlab
ISSUE_COMMENT_REMOVED = 'g_project_management_issue_comment_removed'
class << self
def track_issue_created_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CREATED, author, time)
def track_issue_created_action(author:)
track_unique_action(ISSUE_CREATED, author)
end
def track_issue_title_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_TITLE_CHANGED, author, time)
def track_issue_title_changed_action(author:)
track_unique_action(ISSUE_TITLE_CHANGED, author)
end
def track_issue_description_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_DESCRIPTION_CHANGED, author, time)
def track_issue_description_changed_action(author:)
track_unique_action(ISSUE_DESCRIPTION_CHANGED, author)
end
def track_issue_assignee_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_ASSIGNEE_CHANGED, author, time)
def track_issue_assignee_changed_action(author:)
track_unique_action(ISSUE_ASSIGNEE_CHANGED, author)
end
def track_issue_made_confidential_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MADE_CONFIDENTIAL, author, time)
def track_issue_made_confidential_action(author:)
track_unique_action(ISSUE_MADE_CONFIDENTIAL, author)
end
def track_issue_made_visible_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MADE_VISIBLE, author, time)
def track_issue_made_visible_action(author:)
track_unique_action(ISSUE_MADE_VISIBLE, author)
end
def track_issue_closed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CLOSED, author, time)
def track_issue_closed_action(author:)
track_unique_action(ISSUE_CLOSED, author)
end
def track_issue_reopened_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_REOPENED, author, time)
def track_issue_reopened_action(author:)
track_unique_action(ISSUE_REOPENED, author)
end
def track_issue_label_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_LABEL_CHANGED, author, time)
def track_issue_label_changed_action(author:)
track_unique_action(ISSUE_LABEL_CHANGED, author)
end
def track_issue_milestone_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MILESTONE_CHANGED, author, time)
def track_issue_milestone_changed_action(author:)
track_unique_action(ISSUE_MILESTONE_CHANGED, author)
end
def track_issue_cross_referenced_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CROSS_REFERENCED, author, time)
def track_issue_cross_referenced_action(author:)
track_unique_action(ISSUE_CROSS_REFERENCED, author)
end
def track_issue_moved_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MOVED, author, time)
def track_issue_moved_action(author:)
track_unique_action(ISSUE_MOVED, author)
end
def track_issue_related_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_RELATED, author, time)
def track_issue_related_action(author:)
track_unique_action(ISSUE_RELATED, author)
end
def track_issue_unrelated_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_UNRELATED, author, time)
def track_issue_unrelated_action(author:)
track_unique_action(ISSUE_UNRELATED, author)
end
def track_issue_marked_as_duplicate_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_MARKED_AS_DUPLICATE, author, time)
def track_issue_marked_as_duplicate_action(author:)
track_unique_action(ISSUE_MARKED_AS_DUPLICATE, author)
end
def track_issue_locked_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_LOCKED, author, time)
def track_issue_locked_action(author:)
track_unique_action(ISSUE_LOCKED, author)
end
def track_issue_unlocked_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_UNLOCKED, author, time)
def track_issue_unlocked_action(author:)
track_unique_action(ISSUE_UNLOCKED, author)
end
def track_issue_designs_added_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_DESIGNS_ADDED, author, time)
def track_issue_designs_added_action(author:)
track_unique_action(ISSUE_DESIGNS_ADDED, author)
end
def track_issue_designs_modified_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_DESIGNS_MODIFIED, author, time)
def track_issue_designs_modified_action(author:)
track_unique_action(ISSUE_DESIGNS_MODIFIED, author)
end
def track_issue_designs_removed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_DESIGNS_REMOVED, author, time)
def track_issue_designs_removed_action(author:)
track_unique_action(ISSUE_DESIGNS_REMOVED, author)
end
def track_issue_due_date_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_DUE_DATE_CHANGED, author, time)
def track_issue_due_date_changed_action(author:)
track_unique_action(ISSUE_DUE_DATE_CHANGED, author)
end
def track_issue_time_estimate_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_TIME_ESTIMATE_CHANGED, author, time)
def track_issue_time_estimate_changed_action(author:)
track_unique_action(ISSUE_TIME_ESTIMATE_CHANGED, author)
end
def track_issue_time_spent_changed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_TIME_SPENT_CHANGED, author, time)
def track_issue_time_spent_changed_action(author:)
track_unique_action(ISSUE_TIME_SPENT_CHANGED, author)
end
def track_issue_comment_added_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_COMMENT_ADDED, author, time)
def track_issue_comment_added_action(author:)
track_unique_action(ISSUE_COMMENT_ADDED, author)
end
def track_issue_comment_edited_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_COMMENT_EDITED, author, time)
def track_issue_comment_edited_action(author:)
track_unique_action(ISSUE_COMMENT_EDITED, author)
end
def track_issue_comment_removed_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_COMMENT_REMOVED, author, time)
def track_issue_comment_removed_action(author:)
track_unique_action(ISSUE_COMMENT_REMOVED, author)
end
def track_issue_cloned_action(author:, time: Time.zone.now)
track_unique_action(ISSUE_CLONED, author, time)
def track_issue_cloned_action(author:)
track_unique_action(ISSUE_CLONED, author)
end
private
def track_unique_action(action, author, time)
def track_unique_action(action, author)
return unless author
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id, time: time)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id)
end
end
end
......
......@@ -3,9 +3,10 @@
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_gitlab_redis_shared_state do
let(:user1) { build(:user, id: 1) }
let(:user2) { build(:user, id: 2) }
let(:user3) { build(:user, id: 3) }
let_it_be(:user1) { build(:user, id: 1) }
let_it_be(:user2) { build(:user, id: 2) }
let_it_be(:user3) { build(:user, id: 3) }
let(:time) { Time.zone.now }
context 'for Issue title edit actions' do
......@@ -272,10 +273,13 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
described_class.track_issue_title_changed_action(author: user1)
described_class.track_issue_description_changed_action(author: user1)
described_class.track_issue_assignee_changed_action(author: user1)
described_class.track_issue_title_changed_action(author: user2, time: time - 2.days)
described_class.track_issue_title_changed_action(author: user3, time: time - 3.days)
described_class.track_issue_description_changed_action(author: user3, time: time - 3.days)
described_class.track_issue_assignee_changed_action(author: user3, time: time - 3.days)
travel_to(2.days.ago) do
described_class.track_issue_title_changed_action(author: user2)
described_class.track_issue_title_changed_action(author: user3)
described_class.track_issue_description_changed_action(author: user3)
described_class.track_issue_assignee_changed_action(author: user3)
end
events = Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category(described_class::ISSUE_CATEGORY)
today_count = Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: events, start_date: time, end_date: time)
......
......@@ -14,10 +14,6 @@ RSpec.shared_examples 'a daily tracked issuable event' do
expect(track_action(author: user1)).to be_truthy
expect(track_action(author: user1)).to be_truthy
expect(track_action(author: user2)).to be_truthy
expect(track_action(author: user3, time: time - 3.days)).to be_truthy
expect(count_unique(date_from: time, date_to: time)).to eq(2)
expect(count_unique(date_from: time - 5.days, date_to: 1.day.since(time))).to eq(3)
end
end
......
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