You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/07/15 04:41:08 UTC
(incubator-devlake) branch main updated: fix(jira): fix account id when there is no from/to values (#7734)
This is an automated email from the ASF dual-hosted git repository.
abeizn 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 d7f8583dc fix(jira): fix account id when there is no from/to values (#7734)
d7f8583dc is described below
commit d7f8583dc2f6791ab36d3194bbb91d69653e107d
Author: Lynwee <li...@merico.dev>
AuthorDate: Mon Jul 15 12:41:04 2024 +0800
fix(jira): fix account id when there is no from/to values (#7734)
---
.../jira/tasks/issue_changelog_convertor.go | 51 +++++++++++-----------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/backend/plugins/jira/tasks/issue_changelog_convertor.go b/backend/plugins/jira/tasks/issue_changelog_convertor.go
index d4cdc7998..1eeafb131 100644
--- a/backend/plugins/jira/tasks/issue_changelog_convertor.go
+++ b/backend/plugins/jira/tasks/issue_changelog_convertor.go
@@ -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)
}
}
@@ -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