Commit 98a1ed34 authored by Amparo Luna's avatar Amparo Luna Committed by Douglas Barbosa Alexandre

Expose seats_in_use in namespace entity

parent 61759175
......@@ -87,10 +87,12 @@ the `plan` parameter associated with a namespace:
]
```
Users on GitLab.com will also see a `max_seats_used` parameter. `max_seats_used`
is the highest number of users the group had.
Users on GitLab.com will also see `max_seats_used` and `seats_in_use` parameters.
`max_seats_used` is the highest number of users the group had. `seats_in_use` is
the number of license seats currently being used. Both values are updated
once a day.
`max_seats_used` will be non-zero only for namespaces on paid plans.
`max_seats_used` and `seats_in_use` will be non-zero only for namespaces on paid plans.
```json
[
......@@ -99,6 +101,7 @@ is the highest number of users the group had.
"name": "user1",
"billable_members_count": 2,
"max_seats_used": 3,
"seats_in_use": 2,
...
}
]
......@@ -141,6 +144,7 @@ Example response:
"members_count_with_descendants": 2,
"billable_members_count": 2,
"max_seats_used": 0,
"seats_in_use": 0,
"plan": "default",
"trial_ends_on": null,
"trial": false
......@@ -181,6 +185,7 @@ Example response:
"members_count_with_descendants": 2,
"billable_members_count": 2,
"max_seats_used": 0,
"seats_in_use": 0,
"plan": "default",
"trial_ends_on": null,
"trial": false
......@@ -208,6 +213,7 @@ Example response:
"members_count_with_descendants": 2,
"billable_members_count": 2,
"max_seats_used": 0,
"seats_in_use": 0,
"plan": "default",
"trial_ends_on": null,
"trial": false
......
---
title: Expose seats_in_use in namespace entity
merge_request: 45316
author:
type: added
......@@ -18,6 +18,9 @@ module EE
expose :billable_members_count do |namespace, options|
namespace.billable_members_count(options[:requested_hosted_plan])
end
expose :seats_in_use, if: has_gitlab_subscription do |namespace, _|
namespace.gitlab_subscription.seats_in_use
end
expose :max_seats_used, if: has_gitlab_subscription do |namespace, _|
namespace.gitlab_subscription.max_seats_used
end
......
......@@ -120,7 +120,7 @@ RSpec.describe API::Namespaces do
before do
group1.add_guest(user)
create(:gitlab_subscription, namespace: group1, max_seats_used: 1)
create(:gitlab_subscription, namespace: group1, max_seats_used: 1, seats_in_use: 1)
end
it "avoids additional N+1 database queries" do
......@@ -146,6 +146,12 @@ RSpec.describe API::Namespaces do
expect(json_response.first['max_seats_used']).to eq(1)
end
it 'includes seats_in_use' do
get api("/namespaces", user)
expect(json_response.first['seats_in_use']).to eq(1)
end
end
context 'without gitlab subscription' do
......@@ -156,6 +162,14 @@ RSpec.describe API::Namespaces do
expect(resp.keys).not_to include('max_seats_used')
end
end
it 'does not include seats_in_use' do
get api("/namespaces", user)
json_response.each do |resp|
expect(resp.keys).not_to include('seats_in_use')
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