apache / incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
https://devlake.apache.org/
Apache License 2.0
2.57k stars 514 forks source link

[Bug][GitLab] account ID is not normalized #7585

Closed usharerose closed 3 months ago

usharerose commented 3 months ago

Search before asking

What happened

GitLab plugin provides Convert MR Assignees and Convert MR Reviewers subtasks. In Domain Layer data, account-related ID values are original one from raw data, not converting to normalized one.

Screenshot 2024-06-07 at 14 29 36

What do you expect to happen

Should be normalized account ID

How to reproduce

Trigger GitLab tasks

Anything else

No response

Version

6a9c0eb4d28a80e1302ba5e1c73e8dc5cfc371bc

Are you willing to submit PR?

Code of Conduct

dosubot[bot] commented 3 months ago

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.

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:

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:

Additionally, the ConvertAccounts function in the Convert Users subtask demonstrates a similar normalization process for GitLab accounts, ensuring consistency across different types of data [3].

To continue talking to Dosu, mention @dosu.