Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jira): fix account id when there is no from/to values #7734

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions backend/plugins/jira/tasks/issue_changelog_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,33 +159,13 @@ func ConvertIssueChangelogs(subtaskCtx plugin.SubTaskContext) errors.Error {
changelog.ToValue = getStdStatus(toStatus.StatusCategory)
}
default:
// process other account-like fields, it works on jira9 and jira cloud.
if row.TmpFromAccountId != "" {
if row.FromValue != "" {
changelog.OriginalFromValue = accountIdGen.Generate(connectionId, row.FromValue)
} else {
changelog.OriginalFromValue = accountIdGen.Generate(connectionId, row.TmpFromAccountId)
}
fromAccountId := tryToResolveAccountIdFromAccountLikeField(row.Field, row.TmpFromAccountId, row.FromValue, issueFieldMap)
if fromAccountId != "" {
changelog.OriginalFromValue = accountIdGen.Generate(connectionId, fromAccountId)
}
if row.TmpToAccountId != "" {
if row.ToValue != "" {
changelog.OriginalToValue = accountIdGen.Generate(connectionId, row.ToValue)
} else {
changelog.OriginalToValue = accountIdGen.Generate(connectionId, row.TmpToAccountId)
}
}
if row.TmpFromAccountId == "" && row.TmpToAccountId == "" {
// it works on jira8
// notice: field name is not unique, but we cannot fetch field id here.
if v, ok := issueFieldMap[row.Field]; ok && v.SchemaType == "user" {
// field type is account
if row.FromValue != "" {
changelog.OriginalFromValue = accountIdGen.Generate(connectionId, row.FromValue)
}
if row.ToValue != "" {
changelog.OriginalToValue = accountIdGen.Generate(connectionId, row.ToValue)
}
}
toAccountId := tryToResolveAccountIdFromAccountLikeField(row.Field, row.TmpFromAccountId, row.FromValue, issueFieldMap)
if toAccountId != "" {
changelog.OriginalToValue = accountIdGen.Generate(connectionId, toAccountId)
}
}

Expand All @@ -201,6 +181,25 @@ func ConvertIssueChangelogs(subtaskCtx plugin.SubTaskContext) errors.Error {
return converter.Execute()
}

func tryToResolveAccountIdFromAccountLikeField(fieldName string, tmpAccountId string, fromOrToValue string, issueFieldMap map[string]models.JiraIssueField) string {
if tmpAccountId != "" {
// process other account-like fields, it works on jira9 and jira cloud.
if fromOrToValue != "" {
return fromOrToValue
} else {
return tmpAccountId
}
} else {
// it works on jira8
// notice: field name is not unique, but we cannot fetch field id here.
if v, ok := issueFieldMap[fieldName]; ok && v.SchemaType == "user" {
// field type is account
return fromOrToValue
}
}
return ""
}

func convertIds(ids string, connectionId uint64, sprintIdGenerator *didgen.DomainIdGenerator) (string, errors.Error) {
ss := strings.Split(ids, ",")
var resultSlice []string
Expand Down
Loading