Commit ccae3d56 authored by Mikolaj Wawrzyniak's avatar Mikolaj Wawrzyniak

Fix order in monthly events boundary query

Upper boundary for monthly rage of manage events Service Ping metric
was using wrong ordering, resulting in to small range being selected

Changelog: fixed
parent fb66f975
......@@ -727,7 +727,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable UsageData/LargeTable
start = ::Event.where(time_period).select(:id).order(created_at: :asc).first&.id
finish = ::Event.where(time_period).select(:id).order(created_at: :asc).first&.id
finish = ::Event.where(time_period).select(:id).order(created_at: :desc).first&.id
estimate_batch_distinct_count(::Event.where(time_period), :author_id, start: start, finish: finish)
# rubocop: enable UsageData/LargeTable
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -199,7 +199,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
for_defined_days_back do
user = create(:user)
user2 = create(:user)
create(:event, author: user)
create(:group_member, user: user)
create(:authentication_event, user: user, provider: :ldapmain, result: :success)
create(:authentication_event, user: user2, provider: :ldapsecondary, result: :success)
......@@ -208,17 +207,24 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
create(:authentication_event, user: user, provider: :group_saml, result: :failed)
end
for_defined_days_back(days: [31, 29, 3]) do
create(:event)
end
stub_const('Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE', 1)
stub_const('Gitlab::Database::PostgresHll::BatchDistinctCounter::MIN_REQUIRED_BATCH_SIZE', 0)
expect(described_class.usage_activity_by_stage_manage({})).to include(
events: -1,
groups: 2,
users_created: 6,
users_created: 10,
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: be_within(error_rate).percent_of(1),
events: be_within(error_rate).percent_of(2),
groups: 1,
users_created: 3,
users_created: 6,
omniauth_providers: ['google_oauth2'],
user_auth_by_provider: { 'group_saml' => 1, 'ldap' => 2, 'standard' => 0, 'two-factor' => 0, 'two-factor-via-u2f-device' => 0, "two-factor-via-webauthn-device" => 0 }
)
......
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