Commit d3d90022 authored by Jarka Košanová's avatar Jarka Košanová

Remove time param

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