Commit fe110d6c authored by Imre Farkas's avatar Imre Farkas

Merge branch '241980-uploalds-on-storage-graphql' into 'master'

GraphQL for new uploads in storage types

See merge request gitlab-org/gitlab!47820
parents 210dcb80 3b502092
...@@ -10,18 +10,20 @@ module Types ...@@ -10,18 +10,20 @@ module Types
description: 'Commit count of the project' description: 'Commit count of the project'
field :storage_size, GraphQL::FLOAT_TYPE, null: false, field :storage_size, GraphQL::FLOAT_TYPE, null: false,
description: 'Storage size of the project' description: 'Storage size of the project in bytes'
field :repository_size, GraphQL::FLOAT_TYPE, null: false, field :repository_size, GraphQL::FLOAT_TYPE, null: false,
description: 'Repository size of the project' description: 'Repository size of the project in bytes'
field :lfs_objects_size, GraphQL::FLOAT_TYPE, null: false, field :lfs_objects_size, GraphQL::FLOAT_TYPE, null: false,
description: 'Large File Storage (LFS) object size of the project' description: 'Large File Storage (LFS) object size of the project in bytes'
field :build_artifacts_size, GraphQL::FLOAT_TYPE, null: false, field :build_artifacts_size, GraphQL::FLOAT_TYPE, null: false,
description: 'Build artifacts size of the project' description: 'Build artifacts size of the project in bytes'
field :packages_size, GraphQL::FLOAT_TYPE, null: false, field :packages_size, GraphQL::FLOAT_TYPE, null: false,
description: 'Packages size of the project' description: 'Packages size of the project in bytes'
field :wiki_size, GraphQL::FLOAT_TYPE, null: true, field :wiki_size, GraphQL::FLOAT_TYPE, null: true,
description: 'Wiki size of the project' description: 'Wiki size of the project in bytes'
field :snippets_size, GraphQL::FLOAT_TYPE, null: true, field :snippets_size, GraphQL::FLOAT_TYPE, null: true,
description: 'Snippets size of the project' description: 'Snippets size of the project in bytes'
field :uploads_size, GraphQL::FLOAT_TYPE, null: true,
description: 'Uploads size of the project in bytes'
end end
end end
...@@ -14,5 +14,6 @@ module Types ...@@ -14,5 +14,6 @@ module Types
field :wiki_size, GraphQL::FLOAT_TYPE, null: false, description: 'The wiki size in bytes' field :wiki_size, GraphQL::FLOAT_TYPE, null: false, description: 'The wiki size in bytes'
field :snippets_size, GraphQL::FLOAT_TYPE, null: false, description: 'The snippets size in bytes' field :snippets_size, GraphQL::FLOAT_TYPE, null: false, description: 'The snippets size in bytes'
field :pipeline_artifacts_size, GraphQL::FLOAT_TYPE, null: false, description: 'The CI pipeline artifacts size in bytes' field :pipeline_artifacts_size, GraphQL::FLOAT_TYPE, null: false, description: 'The CI pipeline artifacts size in bytes'
field :uploads_size, GraphQL::FLOAT_TYPE, null: false, description: 'The uploads size in bytes'
end end
end end
---
title: 'GraphQL: Expose uploads_size for project_statistics and root_storage_statistics'
merge_request: 47820
author:
type: added
...@@ -17066,7 +17066,7 @@ type ProjectPermissions { ...@@ -17066,7 +17066,7 @@ type ProjectPermissions {
type ProjectStatistics { type ProjectStatistics {
""" """
Build artifacts size of the project Build artifacts size of the project in bytes
""" """
buildArtifactsSize: Float! buildArtifactsSize: Float!
...@@ -17076,32 +17076,37 @@ type ProjectStatistics { ...@@ -17076,32 +17076,37 @@ type ProjectStatistics {
commitCount: Float! commitCount: Float!
""" """
Large File Storage (LFS) object size of the project Large File Storage (LFS) object size of the project in bytes
""" """
lfsObjectsSize: Float! lfsObjectsSize: Float!
""" """
Packages size of the project Packages size of the project in bytes
""" """
packagesSize: Float! packagesSize: Float!
""" """
Repository size of the project Repository size of the project in bytes
""" """
repositorySize: Float! repositorySize: Float!
""" """
Snippets size of the project Snippets size of the project in bytes
""" """
snippetsSize: Float snippetsSize: Float
""" """
Storage size of the project Storage size of the project in bytes
""" """
storageSize: Float! storageSize: Float!
""" """
Wiki size of the project Uploads size of the project in bytes
"""
uploadsSize: Float
"""
Wiki size of the project in bytes
""" """
wikiSize: Float wikiSize: Float
} }
...@@ -18885,6 +18890,11 @@ type RootStorageStatistics { ...@@ -18885,6 +18890,11 @@ type RootStorageStatistics {
""" """
storageSize: Float! storageSize: Float!
"""
The uploads size in bytes
"""
uploadsSize: Float!
""" """
The wiki size in bytes The wiki size in bytes
""" """
......
...@@ -49615,7 +49615,7 @@ ...@@ -49615,7 +49615,7 @@
"fields": [ "fields": [
{ {
"name": "buildArtifactsSize", "name": "buildArtifactsSize",
"description": "Build artifacts size of the project", "description": "Build artifacts size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49651,7 +49651,7 @@ ...@@ -49651,7 +49651,7 @@
}, },
{ {
"name": "lfsObjectsSize", "name": "lfsObjectsSize",
"description": "Large File Storage (LFS) object size of the project", "description": "Large File Storage (LFS) object size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49669,7 +49669,7 @@ ...@@ -49669,7 +49669,7 @@
}, },
{ {
"name": "packagesSize", "name": "packagesSize",
"description": "Packages size of the project", "description": "Packages size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49687,7 +49687,7 @@ ...@@ -49687,7 +49687,7 @@
}, },
{ {
"name": "repositorySize", "name": "repositorySize",
"description": "Repository size of the project", "description": "Repository size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49705,7 +49705,7 @@ ...@@ -49705,7 +49705,7 @@
}, },
{ {
"name": "snippetsSize", "name": "snippetsSize",
"description": "Snippets size of the project", "description": "Snippets size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49719,7 +49719,7 @@ ...@@ -49719,7 +49719,7 @@
}, },
{ {
"name": "storageSize", "name": "storageSize",
"description": "Storage size of the project", "description": "Storage size of the project in bytes",
"args": [ "args": [
], ],
...@@ -49735,9 +49735,23 @@ ...@@ -49735,9 +49735,23 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "uploadsSize",
"description": "Uploads size of the project in bytes",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "wikiSize", "name": "wikiSize",
"description": "Wiki size of the project", "description": "Wiki size of the project in bytes",
"args": [ "args": [
], ],
...@@ -54533,6 +54547,24 @@ ...@@ -54533,6 +54547,24 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "uploadsSize",
"description": "The uploads size in bytes",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Float",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "wikiSize", "name": "wikiSize",
"description": "The wiki size in bytes", "description": "The wiki size in bytes",
...@@ -2435,14 +2435,15 @@ Represents a Project Membership. ...@@ -2435,14 +2435,15 @@ Represents a Project Membership.
| Field | Type | Description | | Field | Type | Description |
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `buildArtifactsSize` | Float! | Build artifacts size of the project | | `buildArtifactsSize` | Float! | Build artifacts size of the project in bytes |
| `commitCount` | Float! | Commit count of the project | | `commitCount` | Float! | Commit count of the project |
| `lfsObjectsSize` | Float! | Large File Storage (LFS) object size of the project | | `lfsObjectsSize` | Float! | Large File Storage (LFS) object size of the project in bytes |
| `packagesSize` | Float! | Packages size of the project | | `packagesSize` | Float! | Packages size of the project in bytes |
| `repositorySize` | Float! | Repository size of the project | | `repositorySize` | Float! | Repository size of the project in bytes |
| `snippetsSize` | Float | Snippets size of the project | | `snippetsSize` | Float | Snippets size of the project in bytes |
| `storageSize` | Float! | Storage size of the project | | `storageSize` | Float! | Storage size of the project in bytes |
| `wikiSize` | Float | Wiki size of the project | | `uploadsSize` | Float | Uploads size of the project in bytes |
| `wikiSize` | Float | Wiki size of the project in bytes |
### PrometheusAlert ### PrometheusAlert
...@@ -2682,6 +2683,7 @@ Autogenerated return type of RevertVulnerabilityToDetected. ...@@ -2682,6 +2683,7 @@ Autogenerated return type of RevertVulnerabilityToDetected.
| `repositorySize` | Float! | The Git repository size in bytes | | `repositorySize` | Float! | The Git repository size in bytes |
| `snippetsSize` | Float! | The snippets size in bytes | | `snippetsSize` | Float! | The snippets size in bytes |
| `storageSize` | Float! | The total storage in bytes | | `storageSize` | Float! | The total storage in bytes |
| `uploadsSize` | Float! | The uploads size in bytes |
| `wikiSize` | Float! | The wiki size in bytes | | `wikiSize` | Float! | The wiki size in bytes |
### RunDASTScanPayload ### RunDASTScanPayload
......
...@@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['ProjectStatistics'] do ...@@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['ProjectStatistics'] do
it 'has all the required fields' do it 'has all the required fields' do
expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size,
:build_artifacts_size, :packages_size, :commit_count, :build_artifacts_size, :packages_size, :commit_count,
:wiki_size, :snippets_size) :wiki_size, :snippets_size, :uploads_size)
end end
end end
...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['RootStorageStatistics'] do ...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['RootStorageStatistics'] do
it 'has all the required fields' do it 'has all the required fields' do
expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size,
:build_artifacts_size, :packages_size, :wiki_size, :snippets_size, :build_artifacts_size, :packages_size, :wiki_size, :snippets_size,
:pipeline_artifacts_size) :pipeline_artifacts_size, :uploads_size)
end end
specify { expect(described_class).to require_graphql_authorizations(:read_statistics) } specify { expect(described_class).to require_graphql_authorizations(:read_statistics) }
......
...@@ -6,7 +6,7 @@ RSpec.describe 'rendering namespace statistics' do ...@@ -6,7 +6,7 @@ RSpec.describe 'rendering namespace statistics' do
include GraphqlHelpers include GraphqlHelpers
let(:namespace) { user.namespace } let(:namespace) { user.namespace }
let!(:statistics) { create(:namespace_root_storage_statistics, namespace: namespace, packages_size: 5.gigabytes) } let!(:statistics) { create(:namespace_root_storage_statistics, namespace: namespace, packages_size: 5.gigabytes, uploads_size: 3.gigabytes) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:query) do let(:query) do
...@@ -28,6 +28,12 @@ RSpec.describe 'rendering namespace statistics' do ...@@ -28,6 +28,12 @@ RSpec.describe 'rendering namespace statistics' do
expect(graphql_data['namespace']['rootStorageStatistics']).not_to be_blank expect(graphql_data['namespace']['rootStorageStatistics']).not_to be_blank
expect(graphql_data['namespace']['rootStorageStatistics']['packagesSize']).to eq(5.gigabytes) expect(graphql_data['namespace']['rootStorageStatistics']['packagesSize']).to eq(5.gigabytes)
end end
it 'includes uploads size if the user can read the statistics' do
post_graphql(query, current_user: user)
expect(graphql_data_at(:namespace, :root_storage_statistics, :uploads_size)).to eq(3.gigabytes)
end
end end
it_behaves_like 'a working namespace with storage statistics query' it_behaves_like 'a working namespace with storage statistics query'
......
...@@ -6,7 +6,7 @@ RSpec.describe 'rendering project statistics' do ...@@ -6,7 +6,7 @@ RSpec.describe 'rendering project statistics' do
include GraphqlHelpers include GraphqlHelpers
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:project_statistics) { create(:project_statistics, project: project, packages_size: 5.gigabytes) } let!(:project_statistics) { create(:project_statistics, project: project, packages_size: 5.gigabytes, uploads_size: 3.gigabytes) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:query) do let(:query) do
...@@ -31,6 +31,12 @@ RSpec.describe 'rendering project statistics' do ...@@ -31,6 +31,12 @@ RSpec.describe 'rendering project statistics' do
expect(graphql_data['project']['statistics']['packagesSize']).to eq(5.gigabytes) expect(graphql_data['project']['statistics']['packagesSize']).to eq(5.gigabytes)
end end
it 'includes uploads size if the user can read the statistics' do
post_graphql(query, current_user: user)
expect(graphql_data_at(:project, :statistics, :uploadsSize)).to eq(3.gigabytes)
end
context 'when the project is public' do context 'when the project is public' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
......
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