fix(gitlab): rollback some fields revert GitlabStartedAt and GitlabFinishedAt to StartedAt and FinishedAt
diff --git a/plugins/gitlab/e2e/pipelines_test.go b/plugins/gitlab/e2e/pipelines_test.go index ec57139..06da4ac 100644 --- a/plugins/gitlab/e2e/pipelines_test.go +++ b/plugins/gitlab/e2e/pipelines_test.go
@@ -58,8 +58,8 @@ "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 46a0333..598620b 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 9e437a9..66f826c 100644 --- a/plugins/gitlab/models/job.go +++ b/plugins/gitlab/models/job.go
@@ -37,9 +37,9 @@ 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 7a5a384..c0af8cf 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 @@ "gorm.io/gorm" ) -type alertPipeline struct{} +type modifyGitlabCI struct{} type GitlabPipeline20220729 struct { ConnectionId uint64 `gorm:"primaryKey"` @@ -39,11 +39,11 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 b47b0d6..247ccc0 100644 --- a/plugins/gitlab/models/migrationscripts/register.go +++ b/plugins/gitlab/models/migrationscripts/register.go
@@ -25,6 +25,6 @@ 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 6f9d353..8e0de87 100644 --- a/plugins/gitlab/models/pipeline.go +++ b/plugins/gitlab/models/pipeline.go
@@ -34,11 +34,11 @@ 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 d7d99d0..a04c956 100644 --- a/plugins/gitlab/tasks/job_extractor.go +++ b/plugins/gitlab/tasks/job_extractor.go
@@ -97,8 +97,8 @@ 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 25885b5..cc783c0 100644 --- a/plugins/gitlab/tasks/pipeline_extractor.go +++ b/plugins/gitlab/tasks/pipeline_extractor.go
@@ -100,17 +100,17 @@ 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 }