Commit 301ea762 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '8418-maximum-users-should-always-reflect-current-counts' into 'master'

Resolve "Maximum Users should always reflect current counts"

Closes #8418

See merge request gitlab-org/gitlab!15810
parents afb60f4c 43936a00
......@@ -18,6 +18,10 @@ module LicenseHelper
HistoricalData.max_historical_user_count
end
def current_active_user_count
License.current&.current_active_users_count || 0
end
def license_message(signed_in: signed_in?, is_admin: current_user&.admin?)
return unless current_license
return unless signed_in
......
......@@ -6,9 +6,9 @@
- else
- licensed_users = 'Unlimited'
- historical = max_historical_user_count
- if historical && restricted && historical > restricted
- users_over_license = historical - restricted
- maximum_user_count = [max_historical_user_count, current_active_user_count].max
- if restricted && maximum_user_count > restricted
- users_over_license = maximum_user_count - restricted
- else
- users_over_license = 0
......@@ -37,10 +37,10 @@
.well-segment.well-centered
%h3.center
Maximum Users:
= number_with_delimiter historical
= number_with_delimiter maximum_user_count
%hr
This is the highest peak of users on your installation since the license started, and this is the minimum
number you need to purchase when you renew your license.
This is the highest peak of users on your installation since the license started, and
this is the minimum number you need to purchase when you renew your license.
.col-sm-4
.info-well.dark-well
.well-segment.well-centered
......@@ -52,4 +52,4 @@
%a{ href: 'https://about.gitlab.com/licensing-faq/' } true-up model
has a retroactive charge for these users at the next renewal. If you want to update your
license sooner to prevent this, please contact
#{mail_to 'renewals@gitlab.com'}.
%a{ href: 'https://support.gitlab.com' } Support.
---
title: Maximum Users metric in Admin Dashboard includes current active user count
merge_request: 15810
author:
type: added
......@@ -68,4 +68,34 @@ describe LicenseHelper do
expect(guest_user_count).to eq(User.active.count - User.active.excluding_guests.count)
end
end
describe '#max_historical_user_count' do
it 'returns the max historical user count' do
count = 5
expect(HistoricalData).to receive(:max_historical_user_count).and_return(count)
expect(max_historical_user_count).to eq(count)
end
end
describe '#current_active_user_count' do
context 'when current license is set' do
it 'returns the current_active_users_count for the current license' do
license = double
allow(License).to receive(:current).and_return(license)
count = 5
allow(license).to receive(:current_active_users_count).and_return(count)
expect(current_active_user_count).to eq(count)
end
end
context 'when current license is not set' do
it 'returns 0' do
allow(License).to receive(:current).and_return(nil)
expect(current_active_user_count).to eq(0)
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