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
# rubocop: disable CodeReuse/ActiveRecord
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),
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' },
......
......@@ -193,6 +193,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
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
stub_config(
omniauth:
......@@ -213,14 +215,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
expect(described_class.usage_activity_by_stage_manage({})).to include(
events: 2,
events: be_within(error_rate).percent_of(2),
groups: 2,
users_created: 6,
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 }
)
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,
users_created: 3,
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