Commit 92b253ab authored by Alper Akgun's avatar Alper Akgun

Merge branch 'mwaw/change_counter_for_usage_activity_by_stage_monthly_manage_events' into 'master'

Change manage events metric counter method

See merge request gitlab-org/gitlab!72975
parents fff0d177 e8e02887
...@@ -536,7 +536,9 @@ module Gitlab ...@@ -536,7 +536,9 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_manage(time_period) def usage_activity_by_stage_manage(time_period)
{ {
events: distinct_count(::Event.where(time_period), :author_id), # rubocop: disable UsageData/LargeTable
events: estimate_batch_distinct_count(::Event.where(time_period), :author_id),
# rubocop: enable UsageData/LargeTable
groups: distinct_count(::GroupMember.where(time_period), :user_id), groups: distinct_count(::GroupMember.where(time_period), :user_id),
users_created: count(::User.where(time_period), start: minimum_id(User), finish: maximum_id(User)), users_created: count(::User.where(time_period), start: minimum_id(User), finish: maximum_id(User)),
omniauth_providers: filtered_omniauth_provider_names.reject { |name| name == 'group_saml' }, omniauth_providers: filtered_omniauth_provider_names.reject { |name| name == 'group_saml' },
......
...@@ -193,6 +193,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -193,6 +193,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end end
describe 'usage_activity_by_stage_manage' do describe 'usage_activity_by_stage_manage' do
let_it_be(:error_rate) { Gitlab::Database::PostgresHll::BatchDistinctCounter::ERROR_RATE }
it 'includes accurate usage_activity_by_stage data' do it 'includes accurate usage_activity_by_stage data' do
stub_config( stub_config(
omniauth: omniauth:
...@@ -213,14 +215,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -213,14 +215,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end end
expect(described_class.usage_activity_by_stage_manage({})).to include( expect(described_class.usage_activity_by_stage_manage({})).to include(
events: 2, events: be_within(error_rate).percent_of(2),
groups: 2, groups: 2,
users_created: 6, users_created: 6,
omniauth_providers: ['google_oauth2'], omniauth_providers: ['google_oauth2'],
user_auth_by_provider: { 'group_saml' => 2, 'ldap' => 4, 'standard' => 0, 'two-factor' => 0, 'two-factor-via-u2f-device' => 0, "two-factor-via-webauthn-device" => 0 } user_auth_by_provider: { 'group_saml' => 2, 'ldap' => 4, 'standard' => 0, 'two-factor' => 0, 'two-factor-via-u2f-device' => 0, "two-factor-via-webauthn-device" => 0 }
) )
expect(described_class.usage_activity_by_stage_manage(described_class.monthly_time_range_db_params)).to include( expect(described_class.usage_activity_by_stage_manage(described_class.monthly_time_range_db_params)).to include(
events: 1, events: be_within(error_rate).percent_of(1),
groups: 1, groups: 1,
users_created: 3, users_created: 3,
omniauth_providers: ['google_oauth2'], omniauth_providers: ['google_oauth2'],
......
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