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 745d375418a4168dcb99f41140192fb46de79fcf
Author: d4x1 <[email protected]>
AuthorDate: Tue Jul 16 11:30:45 2024 +0800

    refactor(jira): remove some codes
---
 backend/plugins/jira/tasks/epic_extractor.go       |  6 +++++-
 .../jira/tasks/issue_changelog_convertor.go        | 24 +++++++---------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/backend/plugins/jira/tasks/epic_extractor.go 
b/backend/plugins/jira/tasks/epic_extractor.go
index c9a981f3d..cf1e7f28b 100644
--- a/backend/plugins/jira/tasks/epic_extractor.go
+++ b/backend/plugins/jira/tasks/epic_extractor.go
@@ -79,8 +79,12 @@ func getIssueFieldMap(db dal.Dal, connectionId uint64, 
logger log.Logger) (map[s
        for _, v := range allIssueFields {
                if _, ok := issueFieldMap[v.Name]; ok {
                        logger.Warn(nil, "filed name %s is duplicated", v.Name)
+                       if v.SchemaType == "user" {
+                               issueFieldMap[v.Name] = v
+                       }
+               } else {
+                       issueFieldMap[v.Name] = v
                }
-               issueFieldMap[v.Name] = v
        }
        return issueFieldMap, nil
 }
diff --git a/backend/plugins/jira/tasks/issue_changelog_convertor.go 
b/backend/plugins/jira/tasks/issue_changelog_convertor.go
index 142b57017..ba8de94f3 100644
--- a/backend/plugins/jira/tasks/issue_changelog_convertor.go
+++ b/backend/plugins/jira/tasks/issue_changelog_convertor.go
@@ -152,16 +152,15 @@ func ConvertIssueChangelogs(subtaskCtx 
plugin.SubTaskContext) errors.Error {
                                        changelog.ToValue = 
getStdStatus(toStatus.StatusCategory)
                                }
                        default:
-                               fromAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.FromValue, 
issueFieldMap)
-                               if fromAccountId != "" {
-                                       changelog.OriginalFromValue = 
accountIdGen.Generate(connectionId, fromAccountId)
-                               }
-                               toAccountId := 
tryToResolveAccountIdFromAccountLikeField(row.Field, row.ToValue, issueFieldMap)
-                               if toAccountId != "" {
-                                       changelog.OriginalToValue = 
accountIdGen.Generate(connectionId, toAccountId)
+                               if v, ok := issueFieldMap[row.FieldId]; ok && 
v.SchemaType == "user" {
+                                       if row.FromValue != "" {
+                                               changelog.OriginalFromValue = 
accountIdGen.Generate(connectionId, row.FromValue)
+                                       }
+                                       if row.ToValue != "" {
+                                               changelog.OriginalToValue = 
accountIdGen.Generate(connectionId, row.ToValue)
+                                       }
                                }
                        }
-
                        return []interface{}{changelog}, nil
 
                },
@@ -174,15 +173,6 @@ func ConvertIssueChangelogs(subtaskCtx 
plugin.SubTaskContext) errors.Error {
        return converter.Execute()
 }
 
-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 ""
-}
-
 func convertIds(ids string, connectionId uint64, sprintIdGenerator 
*didgen.DomainIdGenerator) (string, errors.Error) {
        ss := strings.Split(ids, ",")
        var resultSlice []string

Reply via email to