You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/01/09 08:11:17 UTC

(incubator-devlake) branch release-v0.20 updated: fix: gitLab collection failed with error message Incorrect datetime v… (#6769)

This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v0.20
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.20 by this push:
     new 7aca72617 fix: gitLab collection failed with error message Incorrect datetime v… (#6769)
7aca72617 is described below

commit 7aca7261751f781d7c9f401b21cd375afbf4907c
Author: abeizn <zi...@merico.dev>
AuthorDate: Tue Jan 9 16:01:26 2024 +0800

    fix: gitLab collection failed with error message Incorrect datetime v… (#6769)
    
    * fix: gitLab collection failed with error message Incorrect datetime value: '0000-00-00' for column deployable_user_created_at
    
    * fix: add deployable_user_created_at is null e2e test
---
 .../e2e/raw_tables/_raw_gitlab_api_deployments.csv |  2 +-
 .../snapshot_tables/_tool_gitlab_deployments.csv   |  2 +-
 backend/plugins/gitlab/models/deployment.go        | 28 +++++++-------
 .../plugins/gitlab/tasks/deployment_extractor.go   | 44 +++++++++++-----------
 4 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv b/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv
index 6ef463041..b8f1b1b16 100644
--- a/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv
+++ b/backend/plugins/gitlab/e2e/raw_tables/_raw_gitlab_api_deployments.csv
@@ -1,5 +1,5 @@
 "id","params","data","url","input","created_at"
-1,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13426753,""iid"":1,""ref"":""master"",""sha"":""add237f6852e6108ee8e0246780a54ce909c6087"",""created_at"":""2019-03-13T14:14:24.109Z"",""updated_at"":""2019-03-13T14:17:47.647Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly [...]
+1,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13426753,""iid"":1,""ref"":""master"",""sha"":""add237f6852e6108ee8e0246780a54ce909c6087"",""created_at"":""2019-03-13T14:14:24.109Z"",""updated_at"":""2019-03-13T14:17:47.647Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly [...]
 2,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13432654,""iid"":2,""ref"":""master"",""sha"":""8373d207f0f2cc4414c4b1ad359b5af56e979d59"",""created_at"":""2019-03-13T14:53:48.148Z"",""updated_at"":""2019-03-13T14:57:58.866Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly [...]
 3,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13432768,""iid"":3,""ref"":""master"",""sha"":""35c3a3d82586fa0bcdb2a73b812081ece4e83429"",""created_at"":""2019-03-13T14:55:21.182Z"",""updated_at"":""2019-03-13T15:02:23.332Z"",""user"":{""id"":3466461,""username"":""rankinzheng"",""name"":""Runjin Zheng"",""state"":""active"",""locked"":false,""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/3466461/avatar.png"",""web_url"":""https://gitlab.com/rankinzheng""},""en [...]
 4,"{""ConnectionId"":1,""ProjectId"":12345678}","{""id"":13436532,""iid"":4,""ref"":""deploy"",""sha"":""35c3a3d82586fa0bcdb2a73b812081ece4e83429"",""created_at"":""2019-03-13T15:21:00.302Z"",""updated_at"":""2019-03-13T15:21:27.833Z"",""user"":{""id"":3014346,""username"":""hackwaly"",""name"":""文宇祥"",""state"":""active"",""locked"":false,""avatar_url"":""https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80\u0026d=identicon"",""web_url"":""https://gitlab.com/hackwaly [...]
diff --git a/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv b/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv
index 6b18e243d..063705721 100644
--- a/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv
+++ b/backend/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_deployments.csv
@@ -3,7 +3,7 @@ connection_id,gitlab_id,deployment_id,created_date,updated_date,status,iid,ref,s
 
 Update CI
 
-See merge request meri.co/vdev.co!175",add237f6,Merge branch 'update-gitlab-ci' into 'master',2019-03-13T14:14:24.000+00:00,2019-03-13T14:17:47.640+00:00,176919795,test_deploy_vdev,master,deploy,2019-03-13T14:17:33.559+00:00,failed,0,14.080506,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T14:14:23.884+00:00,51653436,master,add237f6852e6108ee8e024 [...]
+See merge request meri.co/vdev.co!175",add237f6,Merge branch 'update-gitlab-ci' into 'master',2019-03-13T14:14:24.000+00:00,2019-03-13T14:17:47.640+00:00,176919795,test_deploy_vdev,master,deploy,2019-03-13T14:17:33.559+00:00,failed,0,14.080506,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,,,,,,,,2019-03-13T14:14:23.884+00:00,51653436,master,add237f6852e6108ee8e0246780a54ce909c6087,failed,2019 [...]
 1,12345678,13432654,2019-03-13T14:53:48.148+00:00,2019-03-13T14:57:58.866+00:00,completed,2,master,8373d207f0f2cc4414c4b1ad359b5af56e979d59,staging,test_deploy_vdev,yuxiang@meri.co,yuxiang,2019-03-13T14:53:34.000+00:00,8373d207f0f2cc4414c4b1ad359b5af56e979d59,"Try use ssh -i instead of sshpass
 ",8373d207,Try use ssh -i instead of sshpass,2019-03-13T14:53:48.042+00:00,2019-03-13T14:57:58.845+00:00,176953840,test_deploy_vdev,master,deploy,2019-03-13T14:57:46.441+00:00,failed,0,12.403719,0,3014346,文宇祥,hackwaly,active,https://secure.gravatar.com/avatar/5d814c4a23f3346e8bb40f454a039663?s=80&d=identicon,https://gitlab.com/hackwaly,2018-10-20T15:03:58.883+00:00,,,,,,,2019-03-13T14:53:47.930+00:00,51661712,master,8373d207f0f2cc4414c4b1ad359b5af56e979d59,failed,2019-03-13T14:57:59.200+ [...]
 1,12345678,13432768,2019-03-13T14:55:21.182+00:00,2019-03-13T15:02:23.332+00:00,failed,3,master,35c3a3d82586fa0bcdb2a73b812081ece4e83429,staging,test_deploy_vdev,13381258258@163.com,Runjin Zheng,2019-03-13T14:55:17.000+00:00,35c3a3d82586fa0bcdb2a73b812081ece4e83429,"Merge branch '117-change-language-in-intercom' into 'master'
diff --git a/backend/plugins/gitlab/models/deployment.go b/backend/plugins/gitlab/models/deployment.go
index d3a01a064..709fd1351 100644
--- a/backend/plugins/gitlab/models/deployment.go
+++ b/backend/plugins/gitlab/models/deployment.go
@@ -40,13 +40,13 @@ type GitlabDeployment struct {
 	Environment  string `json:"environment" gorm:"type:varchar(255)"`
 	Name         string `json:"name" gorm:"type:varchar(255)"`
 
-	DeployableCommitAuthorEmail string    `json:"deployable_commit_author_email" gorm:"type:varchar(255)"`
-	DeployableCommitAuthorName  string    `json:"deployable_commit_author_name" gorm:"type:varchar(255)"`
-	DeployableCommitCreatedAt   time.Time `json:"deployable_commit_created_at"`
-	DeployableCommitID          string    `json:"deployable_commit_id" gorm:"type:varchar(255)"`
-	DeployableCommitMessage     string    `json:"deployable_commit_message"`
-	DeployableCommitShortID     string    `json:"deployable_commit_short_id" gorm:"type:varchar(255)"`
-	DeployableCommitTitle       string    `json:"deployable_commit_title" gorm:"type:varchar(255)"`
+	DeployableCommitAuthorEmail string     `json:"deployable_commit_author_email" gorm:"type:varchar(255)"`
+	DeployableCommitAuthorName  string     `json:"deployable_commit_author_name" gorm:"type:varchar(255)"`
+	DeployableCommitCreatedAt   *time.Time `json:"deployable_commit_created_at"`
+	DeployableCommitID          string     `json:"deployable_commit_id" gorm:"type:varchar(255)"`
+	DeployableCommitMessage     string     `json:"deployable_commit_message"`
+	DeployableCommitShortID     string     `json:"deployable_commit_short_id" gorm:"type:varchar(255)"`
+	DeployableCommitTitle       string     `json:"deployable_commit_title" gorm:"type:varchar(255)"`
 
 	//DeployableCoverage   any       `json:"deployable_coverage"`
 	DeployableCreatedAt  *time.Time `json:"deployable_created_at"`
@@ -62,13 +62,13 @@ type GitlabDeployment struct {
 	DeployableDuration  *float64   `json:"deployable_duration"`
 	QueuedDuration      float64    `json:"queued_duration"`
 
-	DeployableUserID        int       `json:"deployable_user_id"`
-	DeployableUserName      string    `json:"deployable_user_name" gorm:"type:varchar(255)"`
-	DeployableUserUsername  string    `json:"deployable_user_username" gorm:"type:varchar(255)"`
-	DeployableUserState     string    `json:"deployable_user_state" gorm:"type:varchar(255)"`
-	DeployableUserAvatarURL string    `json:"deployable_user_avatar_url" gorm:"type:varchar(255)"`
-	DeployableUserWebURL    string    `json:"deployable_user_web_url" gorm:"type:varchar(255)"`
-	DeployableUserCreatedAt time.Time `json:"deployable_user_created_at"`
+	DeployableUserID        int        `json:"deployable_user_id"`
+	DeployableUserName      string     `json:"deployable_user_name" gorm:"type:varchar(255)"`
+	DeployableUserUsername  string     `json:"deployable_user_username" gorm:"type:varchar(255)"`
+	DeployableUserState     string     `json:"deployable_user_state" gorm:"type:varchar(255)"`
+	DeployableUserAvatarURL string     `json:"deployable_user_avatar_url" gorm:"type:varchar(255)"`
+	DeployableUserWebURL    string     `json:"deployable_user_web_url" gorm:"type:varchar(255)"`
+	DeployableUserCreatedAt *time.Time `json:"deployable_user_created_at"`
 	//DeployableUserBio          any       `json:"deployable_user_bio"`
 	//DeployableUserLocation     any       `json:"deployable_user_location"`
 	DeployableUserPublicEmail  string `json:"deployable_user_public_email" gorm:"type:varchar(255)"`
diff --git a/backend/plugins/gitlab/tasks/deployment_extractor.go b/backend/plugins/gitlab/tasks/deployment_extractor.go
index d8b2727c8..ca671b28a 100644
--- a/backend/plugins/gitlab/tasks/deployment_extractor.go
+++ b/backend/plugins/gitlab/tasks/deployment_extractor.go
@@ -146,13 +146,13 @@ func (r GitlabDeploymentResp) toGitlabDeployment(connectionId uint64, gitlabId i
 }
 
 type GitlabDeploymentCommit struct {
-	AuthorEmail string    `json:"author_email"`
-	AuthorName  string    `json:"author_name"`
-	CreatedAt   time.Time `json:"created_at"`
-	ID          string    `json:"id"`
-	Message     string    `json:"message"`
-	ShortID     string    `json:"short_id"`
-	Title       string    `json:"title"`
+	AuthorEmail string     `json:"author_email"`
+	AuthorName  string     `json:"author_name"`
+	CreatedAt   *time.Time `json:"created_at"`
+	ID          string     `json:"id"`
+	Message     string     `json:"message"`
+	ShortID     string     `json:"short_id"`
+	Title       string     `json:"title"`
 }
 
 type GitlabDeploymentProject struct {
@@ -160,21 +160,21 @@ type GitlabDeploymentProject struct {
 }
 
 type GitlabDeploymentFullUser struct {
-	ID           int       `json:"id"`
-	Name         string    `json:"name"`
-	Username     string    `json:"username"`
-	State        string    `json:"state"`
-	AvatarURL    string    `json:"avatar_url"`
-	WebURL       string    `json:"web_url"`
-	CreatedAt    time.Time `json:"created_at"`
-	Bio          any       `json:"bio"`
-	Location     any       `json:"location"`
-	PublicEmail  string    `json:"public_email"`
-	Skype        string    `json:"skype"`
-	Linkedin     string    `json:"linkedin"`
-	Twitter      string    `json:"twitter"`
-	WebsiteURL   string    `json:"website_url"`
-	Organization string    `json:"organization"`
+	ID           int        `json:"id"`
+	Name         string     `json:"name"`
+	Username     string     `json:"username"`
+	State        string     `json:"state"`
+	AvatarURL    string     `json:"avatar_url"`
+	WebURL       string     `json:"web_url"`
+	CreatedAt    *time.Time `json:"created_at"`
+	Bio          any        `json:"bio"`
+	Location     any        `json:"location"`
+	PublicEmail  string     `json:"public_email"`
+	Skype        string     `json:"skype"`
+	Linkedin     string     `json:"linkedin"`
+	Twitter      string     `json:"twitter"`
+	WebsiteURL   string     `json:"website_url"`
+	Organization string     `json:"organization"`
 }
 
 type GitlabDeploymentPipeline struct {