Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
d3788c8b
Commit
d3788c8b
authored
Jun 11, 2018
by
Jens Goldhammer
Committed by
Greg Messner
Jun 10, 2018
Browse files
add project statistics information to projects api (#192)
* add project statistics information to Project model
parent
b5db10eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/models/Project.java
View file @
d3788c8b
...
@@ -85,6 +85,7 @@ public class Project {
...
@@ -85,6 +85,7 @@ public class Project {
private
String
webUrl
;
private
String
webUrl
;
private
Boolean
wikiEnabled
;
private
Boolean
wikiEnabled
;
private
Boolean
printingMergeRequestLinkEnabled
;
private
Boolean
printingMergeRequestLinkEnabled
;
private
ProjectStatistics
statistics
;
public
Integer
getApprovalsBeforeMerge
()
{
public
Integer
getApprovalsBeforeMerge
()
{
return
approvalsBeforeMerge
;
return
approvalsBeforeMerge
;
...
@@ -592,7 +593,16 @@ public class Project {
...
@@ -592,7 +593,16 @@ public class Project {
return
(
this
);
return
(
this
);
}
}
public
ProjectStatistics
getStatistics
()
{
return
statistics
;
}
public
void
setStatistics
(
ProjectStatistics
statistics
)
{
this
.
statistics
=
statistics
;
}
public
static
final
boolean
isValid
(
Project
project
)
{
public
static
final
boolean
isValid
(
Project
project
)
{
return
(
project
!=
null
&&
project
.
getId
()
!=
null
);
return
(
project
!=
null
&&
project
.
getId
()
!=
null
);
}
}
}
}
src/main/java/org/gitlab4j/api/models/ProjectStatistics.java
0 → 100644
View file @
d3788c8b
package
org.gitlab4j.api.models
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
/**
* contains sizing information from the project.
* To get this information, the project api has to be called with parameter statistics=true
* which is only allowed for gitlab admins.
*
* Example json from projects api response:
* https://<gitlab>/api/v4//projects?statistics=true
*
* "statistics": {
* "commit_count": 37,
* "storage_size": 1038090,
* "repository_size": 1038090,
* "lfs_objects_size": 0,
* "job_artifacts_size": 0
* }
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
ProjectStatistics
{
long
commitCount
;
long
storageSize
;
long
lfsObjectSize
;
long
jobArtifactsSize
;
public
long
getCommitCount
()
{
return
commitCount
;
}
public
long
getJobArtifactsSize
()
{
return
jobArtifactsSize
;
}
public
long
getLfsObjectSize
()
{
return
lfsObjectSize
;
}
public
long
getStorageSize
()
{
return
storageSize
;
}
public
void
setCommitCount
(
long
commitCount
)
{
this
.
commitCount
=
commitCount
;
}
public
void
setJobArtifactsSize
(
long
jobArtifactsSize
)
{
this
.
jobArtifactsSize
=
jobArtifactsSize
;
}
public
void
setLfsObjectSize
(
long
lfsObjectSize
)
{
this
.
lfsObjectSize
=
lfsObjectSize
;
}
public
void
setStorageSize
(
long
storageSize
)
{
this
.
storageSize
=
storageSize
;
}
}
src/test/java/org/gitlab4j/api/TestProjectApi.java
View file @
d3788c8b
...
@@ -279,6 +279,23 @@ public class TestProjectApi {
...
@@ -279,6 +279,23 @@ public class TestProjectApi {
assertEquals
(
TEST_PROJECT_NAME_1
,
projects
.
get
(
1
).
getName
());
assertEquals
(
TEST_PROJECT_NAME_1
,
projects
.
get
(
1
).
getName
());
}
}
@Test
public
void
testListProjectsWithStatistics
()
throws
GitLabApiException
{
List
<
Project
>
projects
=
gitLabApi
.
getProjectApi
().
getProjects
(
false
,
null
,
Constants
.
ProjectOrderBy
.
NAME
,
Constants
.
SortOrder
.
DESC
,
null
,
false
,
false
,
false
,
false
,
true
);
assertNotNull
(
projects
);
assertTrue
(
projects
.
size
()
>=
2
);
assertNotNull
(
projects
.
get
(
0
).
getStatistics
());
assertNotNull
(
projects
.
get
(
0
).
getStatistics
().
getLfsObjectSize
());
assertNotNull
(
projects
.
get
(
0
).
getStatistics
().
getCommitCount
());
assertNotNull
(
projects
.
get
(
0
).
getStatistics
().
getJobArtifactsSize
());
assertNotNull
(
projects
.
get
(
0
).
getStatistics
().
getStorageSize
());
}
@Test
@Test
public
void
testListProjectsWithParamsViaPager
()
throws
GitLabApiException
{
public
void
testListProjectsWithParamsViaPager
()
throws
GitLabApiException
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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