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

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit e00e728c0a03104ee20f6addc47eb5e96abceeca
Author: Yingchu Chen <[email protected]>
AuthorDate: Wed Aug 3 14:49:14 2022 +0800

    fix(gitlab): rollback some fields
    
    revert GitlabStartedAt and GitlabFinishedAt to StartedAt and FinishedAt
---
 plugins/gitlab/e2e/pipelines_test.go               |  4 ++--
 .../e2e/snapshot_tables/_tool_gitlab_pipelines.csv |  2 +-
 plugins/gitlab/models/job.go                       |  6 ++---
 ...line_and_job.go => 20220729_modify_gilab_ci.go} | 28 +++++++++++-----------
 plugins/gitlab/models/migrationscripts/register.go |  2 +-
 plugins/gitlab/models/pipeline.go                  | 10 ++++----
 plugins/gitlab/tasks/job_extractor.go              |  6 ++---
 plugins/gitlab/tasks/pipeline_extractor.go         | 22 ++++++++---------
 8 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/plugins/gitlab/e2e/pipelines_test.go 
b/plugins/gitlab/e2e/pipelines_test.go
index ec571393..06da4ace 100644
--- a/plugins/gitlab/e2e/pipelines_test.go
+++ b/plugins/gitlab/e2e/pipelines_test.go
@@ -58,8 +58,8 @@ func TestGitlabPipelineDataFlow(t *testing.T) {
                        "sha",
                        "web_url",
                        "duration",
-                       "gitlab_started_at",
-                       "gitlab_finished_at",
+                       "started_at",
+                       "finished_at",
                        "coverage",
                        "_raw_data_params",
                        "_raw_data_table",
diff --git a/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_pipelines.csv 
b/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_pipelines.csv
index 46a0333f..598620b5 100644
--- a/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_pipelines.csv
+++ b/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_pipelines.csv
@@ -1,4 +1,4 @@
-connection_id,gitlab_id,project_id,gitlab_created_at,status,ref,sha,web_url,duration,gitlab_started_at,gitlab_finished_at,coverage,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+connection_id,gitlab_id,project_id,gitlab_created_at,status,ref,sha,web_url,duration,started_at,finished_at,coverage,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
 
1,457474837,12345678,2022-01-27T10:07:09.429+00:00,failed,renovate/pin-dependencies,b1b82852d48b516a18e56c5bab0ebf54b8f4ccfd,https://gitlab.com/merico-dev/ee/charts/-/pipelines/457474837,0,,,,"{""ConnectionId"":1,""ProjectId"":12345678}",_raw_gitlab_api_pipeline,152,
 
1,457474996,12345678,2022-01-27T10:07:18.884+00:00,failed,renovate/jest-monorepo,739ab912e6e1ed27cecd8a2d00bfd6fa52afd90a,https://gitlab.com/merico-dev/ee/charts/-/pipelines/457474996,0,,,,"{""ConnectionId"":1,""ProjectId"":12345678}",_raw_gitlab_api_pipeline,153,
 
1,457475160,12345678,2022-01-27T10:07:26.435+00:00,failed,renovate/lodash-monorepo,44d127e0ab7dbc4bc259b55929c9d00b62fc3bf4,https://gitlab.com/merico-dev/ee/charts/-/pipelines/457475160,0,,,,"{""ConnectionId"":1,""ProjectId"":12345678}",_raw_gitlab_api_pipeline,154,
diff --git a/plugins/gitlab/models/job.go b/plugins/gitlab/models/job.go
index 9e437a9a..66f826c4 100644
--- a/plugins/gitlab/models/job.go
+++ b/plugins/gitlab/models/job.go
@@ -37,9 +37,9 @@ type GitlabJob struct {
        Duration     float64 `gorm:"type:text"`
        WebUrl       string  `gorm:"type:varchar(255)"`
 
-       GitlabCreatedAt  *time.Time
-       GitlabStartedAt  *time.Time
-       GitlabFinishedAt *time.Time
+       GitlabCreatedAt *time.Time
+       StartedAt       *time.Time
+       FinishedAt      *time.Time
 
        common.NoPKModel
 }
diff --git 
a/plugins/gitlab/models/migrationscripts/20220729_pipeline_and_job.go 
b/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
similarity index 82%
rename from plugins/gitlab/models/migrationscripts/20220729_pipeline_and_job.go
rename to plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
index 7a5a384f..c0af8cfe 100644
--- a/plugins/gitlab/models/migrationscripts/20220729_pipeline_and_job.go
+++ b/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
@@ -26,7 +26,7 @@ import (
        "gorm.io/gorm"
 )
 
-type alertPipeline struct{}
+type modifyGitlabCI struct{}
 
 type GitlabPipeline20220729 struct {
        ConnectionId uint64 `gorm:"primaryKey"`
@@ -39,11 +39,11 @@ type GitlabPipeline20220729 struct {
        WebUrl    string `gorm:"type:varchar(255)"`
        Duration  int
 
-       GitlabCreatedAt  *time.Time
-       GitlabUpdatedAt  *time.Time
-       GitlabStartedAt  *time.Time
-       GitlabFinishedAt *time.Time
-       Coverage         string
+       GitlabCreatedAt *time.Time
+       GitlabUpdatedAt *time.Time
+       StartedAt       *time.Time
+       FinishedAt      *time.Time
+       Coverage        string
 
        common.NoPKModel
 }
@@ -66,9 +66,9 @@ type GitlabJob20220729 struct {
        Duration     float64 `gorm:"type:text"`
        WebUrl       string  `gorm:"type:varchar(255)"`
 
-       GitlabCreatedAt  *time.Time
-       GitlabStartedAt  *time.Time
-       GitlabFinishedAt *time.Time
+       GitlabCreatedAt *time.Time
+       StartedAt       *time.Time
+       FinishedAt      *time.Time
 
        common.NoPKModel
 }
@@ -77,7 +77,7 @@ func (GitlabJob20220729) TableName() string {
        return "_tool_gitlab_jobs"
 }
 
-func (*alertPipeline) Up(ctx context.Context, db *gorm.DB) error {
+func (*modifyGitlabCI) Up(ctx context.Context, db *gorm.DB) error {
        err := db.Migrator().DropColumn(&archived.GitlabPipeline{}, 
"started_at")
        if err != nil {
                return err
@@ -92,12 +92,12 @@ func (*alertPipeline) Up(ctx context.Context, db *gorm.DB) 
error {
                return err
        }
 
-       err = db.Migrator().AddColumn(&GitlabPipeline20220729{}, 
"gitlab_started_at")
+       err = db.Migrator().AddColumn(&GitlabPipeline20220729{}, "started_at")
        if err != nil {
                return err
        }
 
-       err = db.Migrator().AddColumn(&GitlabPipeline20220729{}, 
"gitlab_finished_at")
+       err = db.Migrator().AddColumn(&GitlabPipeline20220729{}, "finished_at")
        if err != nil {
                return err
        }
@@ -110,10 +110,10 @@ func (*alertPipeline) Up(ctx context.Context, db 
*gorm.DB) error {
        return nil
 }
 
-func (*alertPipeline) Version() uint64 {
+func (*modifyGitlabCI) Version() uint64 {
        return 20220729231236
 }
 
-func (*alertPipeline) Name() string {
+func (*modifyGitlabCI) Name() string {
        return "pipeline and job"
 }
diff --git a/plugins/gitlab/models/migrationscripts/register.go 
b/plugins/gitlab/models/migrationscripts/register.go
index b47b0d6f..247ccc0a 100644
--- a/plugins/gitlab/models/migrationscripts/register.go
+++ b/plugins/gitlab/models/migrationscripts/register.go
@@ -25,6 +25,6 @@ import (
 func All() []migration.Script {
        return []migration.Script{
                new(addInitTables),
-               new(alertPipeline),
+               new(modifyGitlabCI),
        }
 }
diff --git a/plugins/gitlab/models/pipeline.go 
b/plugins/gitlab/models/pipeline.go
index 6f9d3532..8e0de87f 100644
--- a/plugins/gitlab/models/pipeline.go
+++ b/plugins/gitlab/models/pipeline.go
@@ -34,11 +34,11 @@ type GitlabPipeline struct {
        WebUrl    string `gorm:"type:varchar(255)"`
        Duration  int
 
-       GitlabCreatedAt  *time.Time
-       GitlabUpdatedAt  *time.Time
-       GitlabStartedAt  *time.Time
-       GitlabFinishedAt *time.Time
-       Coverage         string
+       GitlabCreatedAt *time.Time
+       GitlabUpdatedAt *time.Time
+       StartedAt       *time.Time
+       FinishedAt      *time.Time
+       Coverage        string
 
        common.NoPKModel
 }
diff --git a/plugins/gitlab/tasks/job_extractor.go 
b/plugins/gitlab/tasks/job_extractor.go
index d7d99d04..a04c9560 100644
--- a/plugins/gitlab/tasks/job_extractor.go
+++ b/plugins/gitlab/tasks/job_extractor.go
@@ -97,8 +97,8 @@ func convertJob(job *ApiJob, projectId int) 
(*models.GitlabJob, error) {
                Duration:     job.Duration,
                WebUrl:       job.WebUrl,
 
-               GitlabCreatedAt:  helper.Iso8601TimeToTime(job.CreatedAt),
-               GitlabStartedAt:  helper.Iso8601TimeToTime(job.StartedAt),
-               GitlabFinishedAt: helper.Iso8601TimeToTime(job.FinishedAt),
+               GitlabCreatedAt: helper.Iso8601TimeToTime(job.CreatedAt),
+               StartedAt:       helper.Iso8601TimeToTime(job.StartedAt),
+               FinishedAt:      helper.Iso8601TimeToTime(job.FinishedAt),
        }, nil
 }
diff --git a/plugins/gitlab/tasks/pipeline_extractor.go 
b/plugins/gitlab/tasks/pipeline_extractor.go
index 25885b5f..cc783c0d 100644
--- a/plugins/gitlab/tasks/pipeline_extractor.go
+++ b/plugins/gitlab/tasks/pipeline_extractor.go
@@ -100,17 +100,17 @@ func ExtractApiPipelines(taskCtx core.SubTaskContext) 
error {
 
 func convertPipeline(pipeline *ApiPipeline, projectId int) 
(*models.GitlabPipeline, error) {
        gitlabPipeline := &models.GitlabPipeline{
-               GitlabId:         pipeline.Id,
-               ProjectId:        projectId,
-               Ref:              pipeline.Ref,
-               Sha:              pipeline.Sha,
-               WebUrl:           pipeline.WebUrl,
-               Status:           pipeline.Status,
-               GitlabCreatedAt:  helper.Iso8601TimeToTime(pipeline.CreatedAt),
-               GitlabUpdatedAt:  helper.Iso8601TimeToTime(pipeline.UpdatedAt),
-               GitlabStartedAt:  helper.Iso8601TimeToTime(pipeline.StartedAt),
-               GitlabFinishedAt: helper.Iso8601TimeToTime(pipeline.FinishedAt),
-               Duration:         pipeline.Duration,
+               GitlabId:        pipeline.Id,
+               ProjectId:       projectId,
+               Ref:             pipeline.Ref,
+               Sha:             pipeline.Sha,
+               WebUrl:          pipeline.WebUrl,
+               Status:          pipeline.Status,
+               GitlabCreatedAt: helper.Iso8601TimeToTime(pipeline.CreatedAt),
+               GitlabUpdatedAt: helper.Iso8601TimeToTime(pipeline.UpdatedAt),
+               StartedAt:       helper.Iso8601TimeToTime(pipeline.StartedAt),
+               FinishedAt:      helper.Iso8601TimeToTime(pipeline.FinishedAt),
+               Duration:        pipeline.Duration,
        }
        return gitlabPipeline, nil
 }

Reply via email to