Commit 256b36a7 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch '353814-extend-group-api-to-get-billable-members-count-for-a-given-plan' into 'master'

Extend Group API to get billable members count for a given plan

See merge request gitlab-org/gitlab!82049
parents e4aa9355 77038380
......@@ -11097,7 +11097,6 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupadditionalpurchasedstoragesize"></a>`additionalPurchasedStorageSize` | [`Float`](#float) | Additional storage purchased for the root namespace in bytes. |
| <a id="groupautodevopsenabled"></a>`autoDevopsEnabled` | [`Boolean`](#boolean) | Indicates whether Auto DevOps is enabled for all projects within this group. |
| <a id="groupavatarurl"></a>`avatarUrl` | [`String`](#string) | Avatar URL of the group. |
| <a id="groupbillablememberscount"></a>`billableMembersCount` | [`Int`](#int) | Number of billable users in the group. |
| <a id="groupcontacts"></a>`contacts` | [`CustomerRelationsContactConnection`](#customerrelationscontactconnection) | Find contacts of this group. (see [Connections](#connections)) |
| <a id="groupcontainerrepositoriescount"></a>`containerRepositoriesCount` | [`Int!`](#int) | Number of container repositories in the group. |
| <a id="groupcontainslockedprojects"></a>`containsLockedProjects` | [`Boolean!`](#boolean) | Includes at least one project where the repository size exceeds the limit. |
......@@ -11151,6 +11150,18 @@ four standard [pagination arguments](#connection-pagination-arguments):
#### Fields with arguments
##### `Group.billableMembersCount`
Number of billable users in the group.
Returns [`Int`](#int).
###### Arguments
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="groupbillablememberscountrequestedhostedplan"></a>`requestedHostedPlan` | [`String`](#string) | Plan from which to get billable members. |
##### `Group.board`
A single board of the group.
......@@ -85,7 +85,9 @@ module EE
field :billable_members_count, ::GraphQL::Types::Int,
null: true,
description: 'Number of billable users in the group.'
description: 'Number of billable users in the group.' do
argument :requested_hosted_plan, String, required: false, description: 'Plan from which to get billable members.'
end
field :dora,
::Types::DoraType,
......@@ -105,6 +107,10 @@ module EE
description: 'Compliance violations reported on merge requests merged within the group.' \
' Available only when feature flag `compliance_violations_graphql_type` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice.',
resolver: ::Resolvers::ComplianceManagement::MergeRequests::ComplianceViolationResolver
def billable_members_count(requested_hosted_plan: nil)
object.billable_members_count(requested_hosted_plan)
end
end
end
end
......
......@@ -66,6 +66,73 @@ RSpec.describe GitlabSchema.types['Group'] do
end
end
describe 'billable members count' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, namespace: group) }
let_it_be(:user1) { create(:user) }
let_it_be(:user2) { create(:user) }
let_it_be(:user3) { create(:user) }
let_it_be(:user4) { create(:user) }
before do
group.add_developer(user1)
group.add_guest(user2)
project.add_developer(user3)
project.add_guest(user4)
end
it "returns billable users count including guests when no plan is provided" do
query = <<~GQL
query {
group(fullPath: "#{group.full_path}") {
id,
billableMembersCount
}
}
GQL
result = GitlabSchema.execute(query, context: { current_user: user1 }).as_json
billable_members_count = result.dig('data', 'group', 'billableMembersCount')
expect(billable_members_count).to eq(4)
end
it "returns billable users count including guests when a plan that should include guests is provided" do
query = <<~GQL
query {
group(fullPath: "#{group.full_path}") {
id,
billableMembersCount(requestedHostedPlan: "#{::Plan::SILVER}")
}
}
GQL
result = GitlabSchema.execute(query, context: { current_user: user1 }).as_json
billable_members_count = result.dig('data', 'group', 'billableMembersCount')
expect(billable_members_count).to eq(4)
end
it "returns billable users count excluding guests when a plan that should exclude guests is provided" do
query = <<~GQL
query {
group(fullPath: "#{group.full_path}") {
id,
billableMembersCount(requestedHostedPlan: "#{::Plan::ULTIMATE}")
}
}
GQL
result = GitlabSchema.execute(query, context: { current_user: user1 }).as_json
billable_members_count = result.dig('data', 'group', 'billableMembersCount')
expect(billable_members_count).to eq(2)
end
end
describe 'dora field' do
subject { described_class.fields['dora'] }
......
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