This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch 10-cp
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 5513f96ca11412b57300d43767bf95ce5392270a
Author: d4x1 <[email protected]>
AuthorDate: Tue Jul 16 10:29:18 2024 +0800

    fix(jira): don't use `tmpFromAccountId` and `tmpToAccountId` in issue 
changelogs
---
 .../jira/tasks/issue_changelog_convertor.go        | 24 +++++++---------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/backend/plugins/jira/tasks/issue_changelog_convertor.go 
b/backend/plugins/jira/tasks/issue_changelog_convertor.go
index 090674b13..3ad3b7515 100644
--- a/backend/plugins/jira/tasks/issue_changelog_convertor.go
+++ b/backend/plugins/jira/tasks/issue_changelog_convertor.go
@@ -159,11 +159,11 @@ func ConvertIssueChangelogs(subtaskCtx 
plugin.SubTaskContext) errors.Error {
                                        changelog.ToValue = 
getStdStatus(toStatus.StatusCategory)
                                }
                        default:
-                               fromAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.TmpFromAccountId, 
row.FromValue, issueFieldMap)
+                               fromAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.FromValue, 
issueFieldMap)
                                if fromAccountId != "" {
                                        changelog.OriginalFromValue = 
accountIdGen.Generate(connectionId, fromAccountId)
                                }
-                               toAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.TmpToAccountId, 
row.ToValue, issueFieldMap)
+                               toAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.ToValue, issueFieldMap)
                                if toAccountId != "" {
                                        changelog.OriginalToValue = 
accountIdGen.Generate(connectionId, toAccountId)
                                }
@@ -181,21 +181,11 @@ 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
-               }
+func tryToResolveAccountIdFromAccountLikeField(fieldName string, fromOrToValue 
string, issueFieldMap map[string]models.JiraIssueField) string {
+       // 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 ""
 }

Reply via email to