BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
12c34c1c
Commit
12c34c1c
authored
May 04, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '31544-size-of-project-from-api' into 'master'
Resolve "Size of project from API" Closes #31544 See merge request !11013
parents
0f976727
21f5515a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
8 deletions
+53
-8
31544-size-of-project-from-api.yml
changelogs/unreleased/31544-size-of-project-from-api.yml
+4
-0
projects.md
doc/api/projects.md
+26
-3
projects.rb
lib/api/projects.rb
+9
-5
projects_spec.rb
spec/requests/api/projects_spec.rb
+14
-0
No files found.
changelogs/unreleased/31544-size-of-project-from-api.yml
0 → 100644
View file @
12c34c1c
---
title
:
Expose project statistics on single requests via the API
merge_request
:
author
:
doc/api/projects.md
View file @
12c34c1c
...
...
@@ -40,6 +40,7 @@ Parameters:
|
`owned`
| boolean | no | Limit by projects owned by the current user |
|
`membership`
| boolean | no | Limit by projects that the current user is a member of |
|
`starred`
| boolean | no | Limit by projects starred by the current user |
|
`statistics`
| boolean | no | Include project statistics |
```
json
[
...
...
@@ -91,7 +92,14 @@ Parameters:
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
"only_allow_merge_if_all_discussions_are_resolved"
:
false
,
"request_access_enabled"
:
false
"request_access_enabled"
:
false
,
"statistics"
:
{
"commit_count"
:
37
,
"storage_size"
:
1038090
,
"repository_size"
:
1038090
,
"lfs_objects_size"
:
0
,
"job_artifacts_size"
:
0
}
},
{
"id"
:
6
,
...
...
@@ -151,7 +159,14 @@ Parameters:
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
"only_allow_merge_if_all_discussions_are_resolved"
:
false
,
"request_access_enabled"
:
false
"request_access_enabled"
:
false
,
"statistics"
:
{
"commit_count"
:
12
,
"storage_size"
:
2066080
,
"repository_size"
:
2066080
,
"lfs_objects_size"
:
0
,
"job_artifacts_size"
:
0
}
}
]
```
...
...
@@ -170,6 +185,7 @@ Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
|
|
`statistics`
| boolean | no | Include project statistics |
```
json
{
...
...
@@ -241,7 +257,14 @@ Parameters:
],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
"only_allow_merge_if_all_discussions_are_resolved"
:
false
,
"request_access_enabled"
:
false
"request_access_enabled"
:
false
,
"statistics"
:
{
"commit_count"
:
37
,
"storage_size"
:
1038090
,
"repository_size"
:
1038090
,
"lfs_objects_size"
:
0
,
"job_artifacts_size"
:
0
}
}
```
...
...
lib/api/projects.rb
View file @
12c34c1c
...
...
@@ -26,6 +26,10 @@ module API
params
:optional_params
do
use
:optional_params_ce
end
params
:statistics_params
do
optional
:statistics
,
type:
Boolean
,
default:
false
,
desc:
'Include project statistics'
end
end
resource
:projects
do
...
...
@@ -56,10 +60,6 @@ module API
optional
:membership
,
type:
Boolean
,
default:
false
,
desc:
'Limit by projects that the current user is a member of'
end
params
:statistics_params
do
optional
:statistics
,
type:
Boolean
,
default:
false
,
desc:
'Include project statistics'
end
params
:create_params
do
optional
:namespace_id
,
type:
Integer
,
desc:
'Namespace ID for the new project. Default to the user namespace.'
optional
:import_url
,
type:
String
,
desc:
'URL from which the project is imported'
...
...
@@ -85,6 +85,7 @@ module API
end
params
do
use
:collection_params
use
:statistics_params
end
get
do
entity
=
current_user
?
Entities
::
ProjectWithAccess
:
Entities
::
BasicProjectDetails
...
...
@@ -151,10 +152,13 @@ module API
desc
'Get a single project'
do
success
Entities
::
ProjectWithAccess
end
params
do
use
:statistics_params
end
get
":id"
do
entity
=
current_user
?
Entities
::
ProjectWithAccess
:
Entities
::
BasicProjectDetails
present
user_project
,
with:
entity
,
current_user:
current_user
,
user_can_admin_project:
can?
(
current_user
,
:admin_project
,
user_project
)
user_can_admin_project:
can?
(
current_user
,
:admin_project
,
user_project
)
,
statistics:
params
[
:statistics
]
end
desc
'Get events for a single project'
do
...
...
spec/requests/api/projects_spec.rb
View file @
12c34c1c
...
...
@@ -665,6 +665,20 @@ describe API::Projects do
})
end
it
"does not include statistics by default"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
not_to
include
'statistics'
end
it
"includes statistics if requested"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
),
statistics:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
include
'statistics'
end
describe
'permissions'
do
context
'all projects'
do
before
{
project
.
team
<<
[
user
,
:master
]
}
...
...
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