dosubot[bot] commented on issue #7585:
URL:
https://github.com/apache/incubator-devlake/issues/7585#issuecomment-2154223957
<!-- Greeting -->
Hey there, @usharerose! I'm here to assist you with any bugs, questions, or
contributions you have in mind. Let me know how I can help while we wait for a
human maintainer.
<!-- Answer -->
To ensure that the GitLab plugin normalizes account-related ID values for
the `Convert MR Assignees` and `Convert MR Reviewers` subtasks in the Domain
Layer data, the code should use the `didgen.NewDomainIdGenerator` function.
This function generates domain-specific IDs for the merge requests, which are
then used to create normalized `PullRequestAssignee` and `PullRequestReviewer`
objects.
Here is the relevant code snippet that demonstrates this normalization
process for both assignees and reviewers:
```go
mrIdGen := didgen.NewDomainIdGenerator(&models.GitlabMergeRequest{})
converter, err := helper.NewDataConverter(helper.DataConverterArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
InputRowType: reflect.TypeOf(models.GitlabAssignee{}),
Input: cursor,
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
mrAssignee := inputRow.(*models.GitlabAssignee)
domainPrAssigne := &code.PullRequestAssignee{
PullRequestId: mrIdGen.Generate(data.Options.ConnectionId,
mrAssignee.MergeRequestId),
AssigneeId: mrAssignee.AssigneeId,
Name: mrAssignee.Name,
UserName: mrAssignee.Username,
}
return []interface{}{
domainPrAssigne,
}, nil
},
})
converter, err := helper.NewDataConverter(helper.DataConverterArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
InputRowType: reflect.TypeOf(models.GitlabReviewer{}),
Input: cursor,
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
mrReviewer := inputRow.(*models.GitlabReviewer)
domainPrReviewer := &code.PullRequestReviewer{
PullRequestId: mrIdGen.Generate(data.Options.ConnectionId,
mrReviewer.MergeRequestId),
ReviewerId: mrReviewer.ReviewerId,
Name: mrReviewer.Name,
UserName: mrReviewer.Username,
}
return []interface{}{
domainPrReviewer,
}, nil
},
})
```
In this code:
- `mrIdGen := didgen.NewDomainIdGenerator(&models.GitlabMergeRequest{})`
creates a new domain ID generator for GitLab merge requests.
- `mrIdGen.Generate(data.Options.ConnectionId, mrAssignee.MergeRequestId)`
and `mrIdGen.Generate(data.Options.ConnectionId, mrReviewer.MergeRequestId)`
generate normalized domain-specific IDs for each merge request assignee and
reviewer, respectively.
- The generated `PullRequestId` is then used to create `PullRequestAssignee`
and `PullRequestReviewer` objects, ensuring that the ID values are normalized
in the Domain Layer data
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitlab/tasks/mr_assignee_convertor.go)</sup><sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitlab/tasks/mr_reviewer_convertor.go)</sup>.
Additionally, the `ConvertAccounts` function in the `Convert Users` subtask
demonstrates a similar normalization process for GitLab accounts, ensuring
consistency across different types of data
<sup>[[3]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitlab/tasks/account_convertor.go)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]