You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2023/02/13 08:10:57 UTC

[incubator-devlake] branch release-v0.15 updated: fix(tapd): cherrypick #4399#4395 to 0.15 (#4400)

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

warren pushed a commit to branch release-v0.15
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.15 by this push:
     new 259c34606 fix(tapd): cherrypick #4399#4395 to 0.15 (#4400)
259c34606 is described below

commit 259c3460628f4c3d53a87a8c187da3d4cfc6cbf9
Author: Warren Chen <yi...@merico.dev>
AuthorDate: Mon Feb 13 16:10:53 2023 +0800

    fix(tapd): cherrypick #4399#4395 to 0.15 (#4400)
    
    * fix(tapd): convert unicode to string
    
    * fix(tapd): fix order in bug changelog collector
---
 plugins/tapd/tasks/bug_changelog_collector.go   |  2 +-
 plugins/tapd/tasks/story_changelog_extractor.go | 35 +++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/plugins/tapd/tasks/bug_changelog_collector.go b/plugins/tapd/tasks/bug_changelog_collector.go
index 20c242c66..3ed21ab13 100644
--- a/plugins/tapd/tasks/bug_changelog_collector.go
+++ b/plugins/tapd/tasks/bug_changelog_collector.go
@@ -50,7 +50,7 @@ func CollectBugChangelogs(taskCtx core.SubTaskContext) errors.Error {
 			query.Set("workspace_id", fmt.Sprintf("%v", data.Options.WorkspaceId))
 			query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page))
 			query.Set("limit", fmt.Sprintf("%v", reqData.Pager.Size))
-			query.Set("order", "created%20desc")
+			query.Set("order", "created desc")
 			if data.CreatedDateAfter != nil {
 				query.Set("created",
 					fmt.Sprintf(">%s",
diff --git a/plugins/tapd/tasks/story_changelog_extractor.go b/plugins/tapd/tasks/story_changelog_extractor.go
index a9a976f35..f9055b1c8 100644
--- a/plugins/tapd/tasks/story_changelog_extractor.go
+++ b/plugins/tapd/tasks/story_changelog_extractor.go
@@ -20,6 +20,7 @@ package tasks
 import (
 	"encoding/json"
 	"github.com/apache/incubator-devlake/errors"
+	"strconv"
 	"strings"
 
 	"github.com/apache/incubator-devlake/plugins/core"
@@ -89,14 +90,23 @@ func ExtractStoryChangelog(taskCtx core.SubTaskContext) errors.Error {
 						default:
 							item.ValueBeforeParsed = valueBeforeMap.(string)
 						}
+						err = convertUnicode(&item)
+						if err != nil {
+							return nil, err
+						}
 						results = append(results, &item)
 					}
 				default:
 					item.ConnectionId = data.Options.ConnectionId
 					item.ChangelogId = storyChangelog.Id
 					item.Field = fc.Field
-					item.ValueAfterParsed = strings.Trim(string(fc.ValueAfterParsed), `"`)
-					item.ValueBeforeParsed = strings.Trim(string(fc.ValueBeforeParsed), `"`)
+					item.ValueAfterParsed = valueAfterMap.(string)
+					// as ValueAfterParsed is string, valueBeforeMap is always string
+					item.ValueBeforeParsed = valueBeforeMap.(string)
+				}
+				err = convertUnicode(&item)
+				if err != nil {
+					return nil, err
 				}
 				if item.Field == "iteration_id" {
 					iterationFrom, iterationTo, err := parseIterationChangelog(taskCtx, item.ValueBeforeParsed, item.ValueAfterParsed)
@@ -119,3 +129,24 @@ func ExtractStoryChangelog(taskCtx core.SubTaskContext) errors.Error {
 
 	return extractor.Execute()
 }
+
+func unicodeToZh(s string) (string, error) {
+	str, err := strconv.Unquote(strings.Replace(strconv.Quote(s), `\\u`, `\u`, -1))
+	if err != nil {
+		return "", err
+	}
+	return str, nil
+}
+
+func convertUnicode(item *models.TapdStoryChangelogItem) errors.Error {
+	var err errors.Error
+	item.ValueAfterParsed, err = errors.Convert01(unicodeToZh(item.ValueAfterParsed))
+	if err != nil {
+		return err
+	}
+	item.ValueBeforeParsed, err = errors.Convert01(unicodeToZh(item.ValueBeforeParsed))
+	if err != nil {
+		return err
+	}
+	return nil
+}