Skip to content
Snippets Groups Projects
Unverified Commit 67edde9c authored by Luke Bennett's avatar Luke Bennett
Browse files

Fix gitlab.com licenses api timeout

User count queries are too expensive on .com so we
return `1` for `User.current_active_users_count` on .com.
parent 3119656a
No related merge requests found
......@@ -349,6 +349,10 @@ def edition
end
def current_active_users_count
# These count queries are too expensive on .com.
# See https://gitlab.com/gitlab-org/gitlab-ee/issues/11534
return 1 if Gitlab.com?
@current_active_users_count ||= begin
if exclude_guests_from_active_count?
User.active.excluding_guests.count
......
......@@ -617,6 +617,13 @@ def build_license_with_add_ons(add_ons, plan: nil)
expect(license.overage).to eq(10)
end
it 'returns the difference using current_active_users_count as 1 if Gitlab.com' do
expect(Gitlab).to receive(:com?).and_return(true).at_least(:once)
allow(license).to receive(:restricted_user_count) { 0 }
expect(license.overage).to eq(1)
end
it 'returns 0 if the difference is a negative number' do
allow(license).to receive(:restricted_user_count) { 2 }
......
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