Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8d5273b2
Commit
8d5273b2
authored
Oct 19, 2021
by
Ammar Alakkad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show all storage types in project's storage usage
Changelog: other
parent
05914949
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
26 deletions
+48
-26
app/assets/javascripts/projects/storage_counter/utils.js
app/assets/javascripts/projects/storage_counter/utils.js
+0
-4
spec/frontend/fixtures/projects.rb
spec/frontend/fixtures/projects.rb
+26
-0
spec/frontend/projects/storage_counter/mock_data.js
spec/frontend/projects/storage_counter/mock_data.js
+5
-22
spec/frontend/projects/storage_counter/utils_spec.js
spec/frontend/projects/storage_counter/utils_spec.js
+17
-0
No files found.
app/assets/javascripts/projects/storage_counter/utils.js
View file @
8d5273b2
...
...
@@ -14,10 +14,6 @@ export const parseGetProjectStorageResults = (data, helpLinks) => {
}
const
{
storageSize
,
...
storageStatistics
}
=
projectStatistics
;
const
storageTypes
=
PROJECT_STORAGE_TYPES
.
reduce
((
types
,
currentType
)
=>
{
if
(
!
storageStatistics
[
currentType
.
id
])
{
return
types
;
}
const
helpPathKey
=
currentType
.
id
.
replace
(
`Size`
,
`HelpPagePath`
);
const
helpPath
=
helpLinks
[
helpPathKey
];
...
...
spec/frontend/fixtures/projects.rb
View file @
8d5273b2
...
...
@@ -65,5 +65,31 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
expect_graphql_errors_to_be_empty
end
end
context
'project storage count query'
do
before
do
project
.
statistics
.
update!
(
repository_size:
3900000
,
lfs_objects_size:
4800000
,
build_artifacts_size:
400000
,
pipeline_artifacts_size:
400000
,
wiki_size:
300000
,
packages_size:
3800000
,
uploads_size:
900000
)
end
base_input_path
=
'projects/storage_counter/queries/'
base_output_path
=
'graphql/projects/storage_counter/'
query_name
=
'project_storage.query.graphql'
it
"
#{
base_output_path
}#{
query_name
}
.json"
do
query
=
get_graphql_query_as_string
(
"
#{
base_input_path
}#{
query_name
}
"
)
post_graphql
(
query
,
current_user:
user
,
variables:
{
fullPath:
project
.
full_path
})
expect_graphql_errors_to_be_empty
end
end
end
end
spec/frontend/projects/storage_counter/mock_data.js
View file @
8d5273b2
export
const
mockGetProjectStorageCountGraphQLResponse
=
{
data
:
{
project
:
{
id
:
'
gid://gitlab/Project/20
'
,
statistics
:
{
buildArtifactsSize
:
400000.0
,
pipelineArtifactsSize
:
25000.0
,
lfsObjectsSize
:
4800000.0
,
packagesSize
:
3800000.0
,
repositorySize
:
3900000.0
,
snippetsSize
:
1200000.0
,
storageSize
:
15300000.0
,
uploadsSize
:
900000.0
,
wikiSize
:
300000.0
,
__typename
:
'
ProjectStatistics
'
,
},
__typename
:
'
Project
'
,
},
},
};
import
mockGetProjectStorageCountGraphQLResponse
from
'
test_fixtures/graphql/projects/storage_counter/project_storage.query.graphql.json
'
;
export
{
mockGetProjectStorageCountGraphQLResponse
};
export
const
mockEmptyResponse
=
{
data
:
{
project
:
null
}
};
...
...
@@ -37,7 +20,7 @@ export const defaultProvideValues = {
export
const
projectData
=
{
storage
:
{
totalUsage
:
'
1
4.6
MiB
'
,
totalUsage
:
'
1
3.8
MiB
'
,
storageTypes
:
[
{
storageType
:
{
...
...
@@ -84,7 +67,7 @@ export const projectData = {
description
:
'
Shared bits of code and text.
'
,
helpPath
:
'
/snippets
'
,
},
value
:
120000
0
,
value
:
0
,
},
{
storageType
:
{
...
...
spec/frontend/projects/storage_counter/utils_spec.js
View file @
8d5273b2
...
...
@@ -14,4 +14,21 @@ describe('parseGetProjectStorageResults', () => {
),
).
toMatchObject
(
projectData
);
});
it
(
'
includes storage type with size of 0 in returned value
'
,
()
=>
{
const
mockedResponse
=
mockGetProjectStorageCountGraphQLResponse
.
data
;
// ensuring a specific storage type item has size of 0
mockedResponse
.
project
.
statistics
.
repositorySize
=
0
;
const
response
=
parseGetProjectStorageResults
(
mockedResponse
,
defaultProvideValues
.
helpLinks
);
expect
(
response
.
storage
.
storageTypes
).
toEqual
(
expect
.
arrayContaining
([
{
storageType
:
expect
.
any
(
Object
),
value
:
0
,
},
]),
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment