Commit 43936a00 authored by Tyler Amos's avatar Tyler Amos Committed by Douglas Barbosa Alexandre

Include active user count in Users over License

Remove additional text if current user count exceeds historical.
parent afb60f4c
...@@ -18,6 +18,10 @@ module LicenseHelper ...@@ -18,6 +18,10 @@ module LicenseHelper
HistoricalData.max_historical_user_count HistoricalData.max_historical_user_count
end 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?) def license_message(signed_in: signed_in?, is_admin: current_user&.admin?)
return unless current_license return unless current_license
return unless signed_in return unless signed_in
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
- else - else
- licensed_users = 'Unlimited' - licensed_users = 'Unlimited'
- historical = max_historical_user_count - maximum_user_count = [max_historical_user_count, current_active_user_count].max
- if historical && restricted && historical > restricted - if restricted && maximum_user_count > restricted
- users_over_license = historical - restricted - users_over_license = maximum_user_count - restricted
- else - else
- users_over_license = 0 - users_over_license = 0
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
.well-segment.well-centered .well-segment.well-centered
%h3.center %h3.center
Maximum Users: Maximum Users:
= number_with_delimiter historical = number_with_delimiter maximum_user_count
%hr %hr
This is the highest peak of users on your installation since the license started, and this is the minimum This is the highest peak of users on your installation since the license started, and
number you need to purchase when you renew your license. this is the minimum number you need to purchase when you renew your license.
.col-sm-4 .col-sm-4
.info-well.dark-well .info-well.dark-well
.well-segment.well-centered .well-segment.well-centered
...@@ -52,4 +52,4 @@ ...@@ -52,4 +52,4 @@
%a{ href: 'https://about.gitlab.com/licensing-faq/' } true-up model %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 has a retroactive charge for these users at the next renewal. If you want to update your
license sooner to prevent this, please contact 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 ...@@ -68,4 +68,34 @@ describe LicenseHelper do
expect(guest_user_count).to eq(User.active.count - User.active.excluding_guests.count) expect(guest_user_count).to eq(User.active.count - User.active.excluding_guests.count)
end end
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 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