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

abeizn pushed a commit to branch fix-github-time
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/fix-github-time by this push:
     new 86ff72799 fix: incorrect datetime value: '0000-00-00' for column 
latest_updated
86ff72799 is described below

commit 86ff72799b7884cda79b308366b977cc6dcf55bc
Author: abeizn <[email protected]>
AuthorDate: Thu Dec 7 15:43:01 2023 +0800

    fix: incorrect datetime value: '0000-00-00' for column latest_updated
---
 backend/plugins/github/models/deployment.go        | 34 +++++++++++-----------
 .../github_graphql/tasks/deployment_collector.go   |  6 ++--
 .../github_graphql/tasks/deployment_extractor.go   |  4 +--
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/backend/plugins/github/models/deployment.go 
b/backend/plugins/github/models/deployment.go
index 038bc2328..f6d87684a 100644
--- a/backend/plugins/github/models/deployment.go
+++ b/backend/plugins/github/models/deployment.go
@@ -25,23 +25,23 @@ import (
 
 type GithubDeployment struct {
        common.NoPKModel  `json:"-" mapstructure:"-"`
-       ConnectionId      uint64    `json:"connection_id" gorm:"primaryKey"`
-       GithubId          int       `json:"github_id"`
-       Id                string    `json:"id" 
gorm:"type:varchar(255);primaryKey"`
-       DatabaseId        uint      `json:"database_id"`
-       CommitOid         string    `json:"commit_oid" gorm:"type:varchar(255)"`
-       Description       string    `json:"description" 
gorm:"type:varchar(255)"`
-       Environment       string    `json:"environment" 
gorm:"type:varchar(255)"`
-       State             string    `json:"state" gorm:"type:varchar(255)"`
-       LatestStatusState string    `json:"latest_status_state" 
gorm:"type:varchar(255)"`
-       LatestUpdatedDate time.Time `json:"latest_status_update_date"`
-       RepositoryID      string    `json:"repository_id" 
gorm:"type:varchar(255)"`
-       RepositoryName    string    `json:"repository_name" 
gorm:"type:varchar(255)"`
-       RepositoryUrl     string    `json:"repository_url" 
gorm:"type:varchar(255)"`
-       RefName           string    `json:"ref_name" gorm:"type:varchar(255)"`
-       Payload           string    `json:"payload" gorm:"type:text"`
-       CreatedDate       time.Time `json:"created_at"`
-       UpdatedDate       time.Time `json:"updated_at"`
+       ConnectionId      uint64     `json:"connection_id" gorm:"primaryKey"`
+       GithubId          int        `json:"github_id"`
+       Id                string     `json:"id" 
gorm:"type:varchar(255);primaryKey"`
+       DatabaseId        uint       `json:"database_id"`
+       CommitOid         string     `json:"commit_oid" 
gorm:"type:varchar(255)"`
+       Description       string     `json:"description" 
gorm:"type:varchar(255)"`
+       Environment       string     `json:"environment" 
gorm:"type:varchar(255)"`
+       State             string     `json:"state" gorm:"type:varchar(255)"`
+       LatestStatusState string     `json:"latest_status_state" 
gorm:"type:varchar(255)"`
+       LatestUpdatedDate *time.Time `json:"latest_status_update_date"`
+       RepositoryID      string     `json:"repository_id" 
gorm:"type:varchar(255)"`
+       RepositoryName    string     `json:"repository_name" 
gorm:"type:varchar(255)"`
+       RepositoryUrl     string     `json:"repository_url" 
gorm:"type:varchar(255)"`
+       RefName           string     `json:"ref_name" gorm:"type:varchar(255)"`
+       Payload           string     `json:"payload" gorm:"type:text"`
+       CreatedDate       time.Time  `json:"created_at"`
+       UpdatedDate       time.Time  `json:"updated_at"`
 }
 
 func (GithubDeployment) TableName() string {
diff --git a/backend/plugins/github_graphql/tasks/deployment_collector.go 
b/backend/plugins/github_graphql/tasks/deployment_collector.go
index fbd687d49..7ad553dd4 100644
--- a/backend/plugins/github_graphql/tasks/deployment_collector.go
+++ b/backend/plugins/github_graphql/tasks/deployment_collector.go
@@ -70,9 +70,9 @@ type GraphqlQueryDeploymentDeployment struct {
                Prefix string `graphql:"prefix"`
        } `graphql:"ref"`
        LatestStatus struct {
-               Id        string    `graphql:"id"`
-               State     string    `graphql:"state"`
-               UpdatedAt time.Time `json:"updatedAt"`
+               Id        string     `graphql:"id"`
+               State     string     `graphql:"state"`
+               UpdatedAt *time.Time `json:"updatedAt"`
        } `graphql:"latestStatus"`
        Repository struct {
                Id   string `graphql:"id"`
diff --git a/backend/plugins/github_graphql/tasks/deployment_extractor.go 
b/backend/plugins/github_graphql/tasks/deployment_extractor.go
index 730f07b75..408e70ca4 100644
--- a/backend/plugins/github_graphql/tasks/deployment_extractor.go
+++ b/backend/plugins/github_graphql/tasks/deployment_extractor.go
@@ -93,9 +93,7 @@ func convertGithubDeployment(deployment 
GraphqlQueryDeploymentDeployment, connec
                CreatedDate:       deployment.CreatedAt,
                UpdatedDate:       deployment.UpdatedAt,
                LatestStatusState: deployment.LatestStatus.State,
-       }
-       if !deployment.LatestStatus.UpdatedAt.IsZero() {
-               ret.LatestUpdatedDate = deployment.LatestStatus.UpdatedAt
+               LatestUpdatedDate: deployment.LatestStatus.UpdatedAt,
        }
        if deployment.Ref != nil {
                ret.RefName = deployment.Ref.Name

Reply via email to