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
fc6fdede
Commit
fc6fdede
authored
Oct 16, 2021
by
Guillaume CHAUVEL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pipeline artifacts, packages and uploads size to group REST API
Changelog: other
parent
58d66f28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
26 deletions
+52
-26
app/models/namespace.rb
app/models/namespace.rb
+1
-0
doc/api/groups.md
doc/api/groups.md
+8
-6
doc/development/namespaces_storage_statistics.md
doc/development/namespaces_storage_statistics.md
+12
-3
lib/api/entities/group.rb
lib/api/entities/group.rb
+3
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+23
-15
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+5
-2
No files found.
app/models/namespace.rb
View file @
fc6fdede
...
...
@@ -132,6 +132,7 @@ class Namespace < ApplicationRecord
'COALESCE(SUM(ps.snippets_size), 0) AS snippets_size'
,
'COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size'
,
'COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size'
,
'COALESCE(SUM(ps.pipeline_artifacts_size), 0) AS pipeline_artifacts_size'
,
'COALESCE(SUM(ps.packages_size), 0) AS packages_size'
,
'COALESCE(SUM(ps.uploads_size), 0) AS uploads_size'
)
...
...
doc/api/groups.md
View file @
fc6fdede
...
...
@@ -100,13 +100,15 @@ GET /groups?statistics=true
"parent_id"
:
null
,
"created_at"
:
"2020-01-15T12:36:29.590Z"
,
"statistics"
:
{
"storage_size"
:
363
,
"repository_size"
:
33
,
"wiki_size"
:
100
,
"lfs_objects_size"
:
123
,
"job_artifacts_size"
:
57
,
"storage_size"
:
363
,
"repository_size"
:
33
,
"wiki_size"
:
100
,
"lfs_objects_size"
:
123
,
"job_artifacts_size"
:
57
,
"pipeline_artifacts_size"
:
0
,
"packages_size"
:
0
,
"snippets_size"
:
50
"snippets_size"
:
50
,
"uploads_size"
:
0
}
}
]
...
...
doc/development/namespaces_storage_statistics.md
View file @
fc6fdede
...
...
@@ -53,7 +53,10 @@ SELECT split_part("rs".path, '/', 1) as root_path,
COALESCE
(
SUM
(
ps
.
wiki_size
),
0
)
AS
wiki_size
,
COALESCE
(
SUM
(
ps
.
lfs_objects_size
),
0
)
AS
lfs_objects_size
,
COALESCE
(
SUM
(
ps
.
build_artifacts_size
),
0
)
AS
build_artifacts_size
,
COALESCE
(
SUM
(
ps
.
packages_size
),
0
)
AS
packages_size
COALESCE
(
SUM
(
ps
.
pipeline_artifacts_size
),
0
)
AS
pipeline_artifacts_size
,
COALESCE
(
SUM
(
ps
.
packages_size
),
0
)
AS
packages_size
,
COALESCE
(
SUM
(
ps
.
snippets_size
),
0
)
AS
snippets_size
,
COALESCE
(
SUM
(
ps
.
uploads_size
),
0
)
AS
uploads_size
FROM
"projects"
INNER
JOIN
routes
rs
ON
rs
.
source_id
=
projects
.
id
AND
rs
.
source_type
=
'Project'
INNER
JOIN
project_statistics
ps
ON
ps
.
project_id
=
projects
.
id
...
...
@@ -83,7 +86,10 @@ WITH refresh AS (
COALESCE
(
SUM
(
ps
.
wiki_size
),
0
)
AS
wiki_size
,
COALESCE
(
SUM
(
ps
.
lfs_objects_size
),
0
)
AS
lfs_objects_size
,
COALESCE
(
SUM
(
ps
.
build_artifacts_size
),
0
)
AS
build_artifacts_size
,
COALESCE
(
SUM
(
ps
.
packages_size
),
0
)
AS
packages_size
COALESCE
(
SUM
(
ps
.
pipeline_artifacts_size
),
0
)
AS
pipeline_artifacts_size
,
COALESCE
(
SUM
(
ps
.
packages_size
),
0
)
AS
packages_size
,
COALESCE
(
SUM
(
ps
.
snippets_size
),
0
)
AS
snippets_size
,
COALESCE
(
SUM
(
ps
.
uploads_size
),
0
)
AS
uploads_size
FROM
"projects"
INNER
JOIN
routes
rs
ON
rs
.
source_id
=
projects
.
id
AND
rs
.
source_type
=
'Project'
INNER
JOIN
project_statistics
ps
ON
ps
.
project_id
=
projects
.
id
...
...
@@ -94,7 +100,10 @@ SET storage_size = refresh.storage_size,
wiki_size
=
refresh
.
wiki_size
,
lfs_objects_size
=
refresh
.
lfs_objects_size
,
build_artifacts_size
=
refresh
.
build_artifacts_size
,
packages_size
=
refresh
.
packages_size
pipeline_artifacts_size
=
refresh
.
pipeline_artifacts_size
,
packages_size
=
refresh
.
packages_size
,
snippets_size
=
refresh
.
snippets_size
,
uploads_size
=
refresh
.
uploads_size
FROM
refresh
INNER
JOIN
routes
rs
ON
rs
.
path
=
refresh
.
root_path
AND
rs
.
source_type
=
'Namespace'
WHERE
namespace_storage_statistics
.
namespace_id
=
rs
.
source_id
...
...
lib/api/entities/group.rb
View file @
fc6fdede
...
...
@@ -31,7 +31,10 @@ module API
expose
:wiki_size
expose
:lfs_objects_size
expose
:build_artifacts_size
,
as: :job_artifacts_size
expose
:pipeline_artifacts_size
expose
:packages_size
expose
:snippets_size
expose
:uploads_size
end
end
end
...
...
spec/models/namespace_spec.rb
View file @
fc6fdede
...
...
@@ -519,26 +519,30 @@ RSpec.describe Namespace do
create
(
:project
,
namespace:
namespace
,
statistics:
build
(
:project_statistics
,
namespace:
namespace
,
repository_size:
101
,
wiki_size:
505
,
lfs_objects_size:
202
,
build_artifacts_size:
303
,
packages_size:
404
,
snippets_size:
605
))
namespace:
namespace
,
repository_size:
101
,
wiki_size:
505
,
lfs_objects_size:
202
,
build_artifacts_size:
303
,
pipeline_artifacts_size:
707
,
packages_size:
404
,
snippets_size:
605
,
uploads_size:
808
))
end
let
(
:project2
)
do
create
(
:project
,
namespace:
namespace
,
statistics:
build
(
:project_statistics
,
namespace:
namespace
,
repository_size:
10
,
wiki_size:
50
,
lfs_objects_size:
20
,
build_artifacts_size:
30
,
packages_size:
40
,
snippets_size:
60
))
namespace:
namespace
,
repository_size:
10
,
wiki_size:
50
,
lfs_objects_size:
20
,
build_artifacts_size:
30
,
pipeline_artifacts_size:
70
,
packages_size:
40
,
snippets_size:
60
,
uploads_size:
80
))
end
it
"sums all project storage counters in the namespace"
do
...
...
@@ -546,13 +550,15 @@ RSpec.describe Namespace do
project2
statistics
=
described_class
.
with_statistics
.
find
(
namespace
.
id
)
expect
(
statistics
.
storage_size
).
to
eq
2330
expect
(
statistics
.
storage_size
).
to
eq
3995
expect
(
statistics
.
repository_size
).
to
eq
111
expect
(
statistics
.
wiki_size
).
to
eq
555
expect
(
statistics
.
lfs_objects_size
).
to
eq
222
expect
(
statistics
.
build_artifacts_size
).
to
eq
333
expect
(
statistics
.
pipeline_artifacts_size
).
to
eq
777
expect
(
statistics
.
packages_size
).
to
eq
444
expect
(
statistics
.
snippets_size
).
to
eq
665
expect
(
statistics
.
uploads_size
).
to
eq
888
end
it
"correctly handles namespaces without projects"
do
...
...
@@ -563,8 +569,10 @@ RSpec.describe Namespace do
expect
(
statistics
.
wiki_size
).
to
eq
0
expect
(
statistics
.
lfs_objects_size
).
to
eq
0
expect
(
statistics
.
build_artifacts_size
).
to
eq
0
expect
(
statistics
.
pipeline_artifacts_size
).
to
eq
0
expect
(
statistics
.
packages_size
).
to
eq
0
expect
(
statistics
.
snippets_size
).
to
eq
0
expect
(
statistics
.
uploads_size
).
to
eq
0
end
end
...
...
spec/requests/api/groups_spec.rb
View file @
fc6fdede
...
...
@@ -319,12 +319,15 @@ RSpec.describe API::Groups do
it
"includes statistics if requested"
do
attributes
=
{
storage_size:
2392
,
storage_size:
4093
,
repository_size:
123
,
wiki_size:
456
,
lfs_objects_size:
234
,
build_artifacts_size:
345
,
snippets_size:
1234
pipeline_artifacts_size:
456
,
packages_size:
567
,
snippets_size:
1234
,
uploads_size:
678
}.
stringify_keys
exposed_attributes
=
attributes
.
dup
exposed_attributes
[
'job_artifacts_size'
]
=
exposed_attributes
.
delete
(
'build_artifacts_size'
)
...
...
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