Repository: xanzy/go-gitlab
Pull request #1508 (2022-07-23 20:52:03)

feat(project): Add missing StorageStatistics fields
Add missing fields to the `StorageStatistics` struct 


Patch:
diff --git a/groups.go b/groups.go
index 4b77139..cfd9ef5 100644
--- a/groups.go
+++ b/groups.go
@@ -52,7 +52,7 @@ type Group struct {
 	FileTemplateProjectID   int                        `json:"file_template_project_id"`
 	ParentID                int                        `json:"parent_id"`
 	Projects                []*Project                 `json:"projects"`
-	Statistics              *StorageStatistics         `json:"statistics"`
+	Statistics              *Statistics                `json:"statistics"`
 	CustomAttributes        []*CustomAttribute         `json:"custom_attributes"`
 	ShareWithGroupLock      bool                       `json:"share_with_group_lock"`
 	RequireTwoFactorAuth    bool                       `json:"require_two_factor_authentication"`
diff --git a/projects.go b/projects.go
index d9c83d2..ffd42dc 100644
--- a/projects.go
+++ b/projects.go
@@ -121,7 +121,7 @@ type Project struct {
 		GroupName        string `json:"group_name"`
 		GroupAccessLevel int    `json:"group_access_level"`
 	} `json:"shared_with_groups"`
-	Statistics                               *ProjectStatistics `json:"statistics"`
+	Statistics                               *Statistics        `json:"statistics"`
 	Links                                    *Links             `json:"_links,omitempty"`
 	CIConfigPath                             string             `json:"ci_config_path"`
 	CIDefaultGitDepth                        int                `json:"ci_default_git_depth"`
@@ -230,12 +230,6 @@ type ProjectNamespace struct {
 	WebURL    string `json:"web_url"`
 }
 
-// ProjectStatistics represents a statistics record for a project.
-type ProjectStatistics struct {
-	StorageStatistics
-	CommitCount int `json:"commit_count"`
-}
-
 // Repository represents a repository.
 type Repository struct {
 	Name              string          `json:"name"`
@@ -254,12 +248,18 @@ type Repository struct {
 	HTTPURL           string          `json:"http_url"`
 }
 
-// StorageStatistics represents a statistics record for a group or project.
-type StorageStatistics struct {
-	StorageSize      int64 `json:"storage_size"`
-	RepositorySize   int64 `json:"repository_size"`
-	LfsObjectsSize   int64 `json:"lfs_objects_size"`
-	JobArtifactsSize int64 `json:"job_artifacts_size"`
+// Statistics represents a statistics record for a group or project.
+type Statistics struct {
+	CommitCount           int64 `json:"commit_count"`
+	StorageSize           int64 `json:"storage_size"`
+	RepositorySize        int64 `json:"repository_size"`
+	WikiSize              int64 `json:"wiki_size"`
+	LFSObjectsSize        int64 `json:"lfs_objects_size"`
+	JobArtifactsSize      int64 `json:"job_artifacts_size"`
+	PipelineArtifactsSize int64 `json:"pipeline_artifacts_size"`
+	PackagesSize          int64 `json:"packages_size"`
+	SnippetsSize          int64 `json:"snippets_size"`
+	UploadsSize           int64 `json:"uploads_size"`
 }
 
 func (s Project) String() string {


Test patch:
diff --git a/projects_test.go b/projects_test.go
index f495b3f..6ac719a 100644
--- a/projects_test.go
+++ b/projects_test.go
@@ -362,18 +362,26 @@ func TestGetProjectWithOptions(t *testing.T) {
 				"commit_count": 37,
 				"storage_size": 1038090,
 				"repository_size": 1038090,
+				"wiki_size": 10,
 				"lfs_objects_size": 0,
-				"job_artifacts_size": 0
+				"job_artifacts_size": 0,
+				"pipeline_artifacts_size": 0,
+				"packages_size": 238906167,
+				"snippets_size": 146800,
+				"uploads_size": 6523619
 			}}`)
 	})
-	want := &Project{ID: 1, Statistics: &ProjectStatistics{
-		CommitCount: 37,
-		StorageStatistics: StorageStatistics{
-			StorageSize:      1038090,
-			RepositorySize:   1038090,
-			LfsObjectsSize:   0,
-			JobArtifactsSize: 0,
-		},
+	want := &Project{ID: 1, Statistics: &Statistics{
+		CommitCount:           37,
+		StorageSize:           1038090,
+		RepositorySize:        1038090,
+		WikiSize:              10,
+		LFSObjectsSize:        0,
+		JobArtifactsSize:      0,
+		PipelineArtifactsSize: 0,
+		PackagesSize:          238906167,
+		SnippetsSize:          146800,
+		UploadsSize:           6523619,
 	}}
 
 	project, _, err := client.Projects.GetProject(1, &GetProjectOptions{Statistics: Bool(true)})