Commit 5219f392 authored by Marc Shaw's avatar Marc Shaw

Code review: Freeze hash and change class to module

Issue: gitlab.com/gitlab-org/gitlab/-/issues/219956
Merge Request: gitlab.com/gitlab-org/gitlab/-/merge_requests/35580
parent 5d523107
......@@ -577,11 +577,10 @@ module Gitlab
{ analytics_unique_visits: results }
end
# rubocop: disable CodeReuse/ActiveRecord
def action_monthly_active_users(time_period)
return {} unless Feature.enabled?(Gitlab::UsageDataCounters::TrackUniqueActions::FEATURE_FLAG)
counter = Gitlab::UsageDataCounters::TrackUniqueActions.new
counter = Gitlab::UsageDataCounters::TrackUniqueActions
project_count = redis_usage_data do
counter.count_unique_events(
......@@ -613,7 +612,6 @@ module Gitlab
action_monthly_active_users_wiki_repo: wiki_count
}
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -2,7 +2,7 @@
module Gitlab
module UsageDataCounters
class TrackUniqueActions
module TrackUniqueActions
KEY_EXPIRY_LENGTH = 29.days
FEATURE_FLAG = :track_unique_actions
......@@ -24,16 +24,9 @@ module Gitlab
project: {
pushed: PUSH_ACTION
}
})
def self.track_action(params)
self.new.track_action(params)
end
def self.count_unique_events(params)
self.new.count_unique_events(params)
end
}).freeze
class << self
def track_action(event_action:, event_target:, author_id:, time: Time.zone.now)
return unless Gitlab::CurrentSettings.usage_ping_enabled
return unless Feature.enabled?(FEATURE_FLAG)
......@@ -89,4 +82,5 @@ module Gitlab
end
end
end
end
end
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redis_shared_state do
subject(:track_unique_events) { described_class.new }
subject(:track_unique_events) { described_class }
let(:time) { Time.zone.now }
......
......@@ -905,7 +905,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let(:feature_flag) { true }
before do
counter = Gitlab::UsageDataCounters::TrackUniqueActions.new
counter = Gitlab::UsageDataCounters::TrackUniqueActions
project = Event::TARGET_TYPES[:project]
wiki = Event::TARGET_TYPES[:wiki]
design = Event::TARGET_TYPES[:design]
......
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