This is an automated email from the ASF dual-hosted git repository.
lynwee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 13b20bd12 fix: gitlab pr reviewers and assignees id (#7588)
13b20bd12 is described below
commit 13b20bd127a7877f5682092ee2d48f332e5cd445
Author: abeizn <[email protected]>
AuthorDate: Fri Jun 7 16:49:37 2024 +0800
fix: gitlab pr reviewers and assignees id (#7588)
---
.../domainlayer/code/pull_request_assignees.go | 2 +-
.../domainlayer/code/pull_request_reviewers.go | 2 +-
...0240607_modify_pr_assignees_and_reviewers_id.go | 48 ++++++++++++++++++++++
.../archived/pull_request_assignees.go | 2 +-
.../archived/pull_request_reviewers.go | 2 +-
backend/core/models/migrationscripts/register.go | 1 +
.../plugins/gitlab/tasks/mr_assignee_convertor.go | 3 +-
.../plugins/gitlab/tasks/mr_reviewer_convertor.go | 3 +-
8 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/backend/core/models/domainlayer/code/pull_request_assignees.go
b/backend/core/models/domainlayer/code/pull_request_assignees.go
index 22a3ffd1d..662ec9f84 100644
--- a/backend/core/models/domainlayer/code/pull_request_assignees.go
+++ b/backend/core/models/domainlayer/code/pull_request_assignees.go
@@ -23,7 +23,7 @@ import (
type PullRequestAssignee struct {
PullRequestId string `json:"id"
gorm:"primaryKey;type:varchar(255);comment:This key is generated based on
details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
- AssigneeId int `gorm:"primaryKey"`
+ AssigneeId string `gorm:"primaryKey;type:varchar(255);"`
Name string `gorm:"type:varchar(255)"`
UserName string `gorm:"type:varchar(255)"`
diff --git a/backend/core/models/domainlayer/code/pull_request_reviewers.go
b/backend/core/models/domainlayer/code/pull_request_reviewers.go
index 2fdc20d1e..8d99664c6 100644
--- a/backend/core/models/domainlayer/code/pull_request_reviewers.go
+++ b/backend/core/models/domainlayer/code/pull_request_reviewers.go
@@ -23,7 +23,7 @@ import (
type PullRequestReviewer struct {
PullRequestId string `json:"id"
gorm:"primaryKey;type:varchar(255);comment:This key is generated based on
details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
- ReviewerId int `gorm:"primaryKey"`
+ ReviewerId string `gorm:"primaryKey;type:varchar(255);"`
Name string `gorm:"type:varchar(255)"`
UserName string `gorm:"type:varchar(255)"`
diff --git
a/backend/core/models/migrationscripts/20240607_modify_pr_assignees_and_reviewers_id.go
b/backend/core/models/migrationscripts/20240607_modify_pr_assignees_and_reviewers_id.go
new file mode 100644
index 000000000..adfe318ed
--- /dev/null
+++
b/backend/core/models/migrationscripts/20240607_modify_pr_assignees_and_reviewers_id.go
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
+ "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+type modifyPrAssigneeAndReviewerId struct{}
+
+func (u *modifyPrAssigneeAndReviewerId) Up(basicRes context.BasicRes)
errors.Error {
+ db := basicRes.GetDal()
+ err := db.DropTables(&archived.PullRequestAssignee{},
&archived.PullRequestReviewer{})
+ if err != nil {
+ return err
+ }
+ return migrationhelper.AutoMigrateTables(
+ basicRes,
+ &archived.PullRequestAssignee{},
+ &archived.PullRequestReviewer{},
+ )
+}
+
+func (*modifyPrAssigneeAndReviewerId) Version() uint64 {
+ return 20250607000041
+}
+
+func (*modifyPrAssigneeAndReviewerId) Name() string {
+ return "modify pull_request_reviewers and pull_request_assignees id
columns"
+}
diff --git
a/backend/core/models/migrationscripts/archived/pull_request_assignees.go
b/backend/core/models/migrationscripts/archived/pull_request_assignees.go
index d1881b979..d3d578027 100644
--- a/backend/core/models/migrationscripts/archived/pull_request_assignees.go
+++ b/backend/core/models/migrationscripts/archived/pull_request_assignees.go
@@ -19,7 +19,7 @@ package archived
type PullRequestAssignee struct {
PullRequestId string `json:"id"
gorm:"primaryKey;type:varchar(255);comment:This key is generated based on
details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
- AssigneeId int `gorm:"primaryKey"`
+ AssigneeId string `gorm:"primaryKey;type:varchar(255);"`
Name string `gorm:"type:varchar(255)"`
UserName string `gorm:"type:varchar(255)"`
diff --git
a/backend/core/models/migrationscripts/archived/pull_request_reviewers.go
b/backend/core/models/migrationscripts/archived/pull_request_reviewers.go
index 8d47cf052..17d4d156f 100644
--- a/backend/core/models/migrationscripts/archived/pull_request_reviewers.go
+++ b/backend/core/models/migrationscripts/archived/pull_request_reviewers.go
@@ -19,7 +19,7 @@ package archived
type PullRequestReviewer struct {
PullRequestId string `json:"id"
gorm:"primaryKey;type:varchar(255);comment:This key is generated based on
details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
- ReviewerId int `gorm:"primaryKey"`
+ ReviewerId string `gorm:"primaryKey;type:varchar(255);"`
Name string `gorm:"type:varchar(255)"`
UserName string `gorm:"type:varchar(255)"`
diff --git a/backend/core/models/migrationscripts/register.go
b/backend/core/models/migrationscripts/register.go
index 422c2a818..4f3a21824 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -120,5 +120,6 @@ func All() []plugin.MigrationScript {
new(modifyCicdDeploymentCommitsRepoUrlLength),
new(modifyCicdPipelineCommitsRepoUrlLength),
new(addPrAssigneeAndReviewer),
+ new(modifyPrAssigneeAndReviewerId),
}
}
diff --git a/backend/plugins/gitlab/tasks/mr_assignee_convertor.go
b/backend/plugins/gitlab/tasks/mr_assignee_convertor.go
index 3ae9523ee..d638d1dc0 100644
--- a/backend/plugins/gitlab/tasks/mr_assignee_convertor.go
+++ b/backend/plugins/gitlab/tasks/mr_assignee_convertor.go
@@ -64,6 +64,7 @@ func ConvertMrAssignees(taskCtx plugin.SubTaskContext)
errors.Error {
defer cursor.Close()
mrIdGen := didgen.NewDomainIdGenerator(&models.GitlabMergeRequest{})
+ accountIdGen := didgen.NewDomainIdGenerator(&models.GitlabAccount{})
converter, err := helper.NewDataConverter(helper.DataConverterArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
@@ -73,7 +74,7 @@ func ConvertMrAssignees(taskCtx plugin.SubTaskContext)
errors.Error {
mrAssignee := inputRow.(*models.GitlabAssignee)
domainPrAssigne := &code.PullRequestAssignee{
PullRequestId:
mrIdGen.Generate(data.Options.ConnectionId, mrAssignee.MergeRequestId),
- AssigneeId: mrAssignee.AssigneeId,
+ AssigneeId:
accountIdGen.Generate(data.Options.ConnectionId, mrAssignee.AssigneeId),
Name: mrAssignee.Name,
UserName: mrAssignee.Username,
}
diff --git a/backend/plugins/gitlab/tasks/mr_reviewer_convertor.go
b/backend/plugins/gitlab/tasks/mr_reviewer_convertor.go
index dbbf10a14..b702de573 100644
--- a/backend/plugins/gitlab/tasks/mr_reviewer_convertor.go
+++ b/backend/plugins/gitlab/tasks/mr_reviewer_convertor.go
@@ -64,6 +64,7 @@ func ConvertMrReviewers(taskCtx plugin.SubTaskContext)
errors.Error {
defer cursor.Close()
mrIdGen := didgen.NewDomainIdGenerator(&models.GitlabMergeRequest{})
+ accountIdGen := didgen.NewDomainIdGenerator(&models.GitlabAccount{})
converter, err := helper.NewDataConverter(helper.DataConverterArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
@@ -73,7 +74,7 @@ func ConvertMrReviewers(taskCtx plugin.SubTaskContext)
errors.Error {
mrReviewer := inputRow.(*models.GitlabReviewer)
domainPrReviewer := &code.PullRequestReviewer{
PullRequestId:
mrIdGen.Generate(data.Options.ConnectionId, mrReviewer.MergeRequestId),
- ReviewerId: mrReviewer.ReviewerId,
+ ReviewerId:
accountIdGen.Generate(data.Options.ConnectionId, mrReviewer.ReviewerId),
Name: mrReviewer.Name,
UserName: mrReviewer.Username,
}