Skip to content

Commit

Permalink
feat(tapd): add more log when converting unicode (#8164)
Browse files Browse the repository at this point in the history
* feat(tapd): add more log when converting unicode

* feat(tapd): ignore errors when converting unicode fails
  • Loading branch information
d4x1 authored Oct 30, 2024
1 parent f99d5bd commit ded45ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion backend/plugins/tapd/tasks/bug_changelog_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var ExtractBugChangelogMeta = plugin.SubTaskMeta{

func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error {
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_BUG_CHANGELOG_TABLE)
logger := taskCtx.GetLogger()
extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
Expand All @@ -47,6 +48,7 @@ func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err := errors.Convert(json.Unmarshal(row.Data, &bugChangelogBody))
if err != nil {
logger.Error(err, "unmarshal: %s, err: %s", row.Data, err)
return nil, err
}
bugChangelog := bugChangelogBody.BugChange
Expand All @@ -62,11 +64,12 @@ func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err = convertUnicode(item)
if err != nil {
return nil, err
logger.Error(err, "convert unicode: %s, err: %s", item, err)
}
if item.Field == "iteration_id" {
iterationFrom, iterationTo, err := parseIterationChangelog(taskCtx, item.ValueBeforeParsed, item.ValueAfterParsed)
if err != nil {
logger.Error(err, "parseIterationChangelog: %s, err: %s", item, err)
return nil, err
}
item.IterationIdFrom = iterationFrom
Expand Down
5 changes: 3 additions & 2 deletions backend/plugins/tapd/tasks/story_changelog_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var ExtractStoryChangelogMeta = plugin.SubTaskMeta{
}

func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error {
logger := taskCtx.GetLogger()
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_STORY_CHANGELOG_TABLE)
extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
Expand Down Expand Up @@ -89,7 +90,7 @@ func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err = convertUnicode(&item)
if err != nil {
return nil, err
logger.Error(err, "convert unicode: %s, err: %s", item, err)
}
results = append(results, &item)
}
Expand All @@ -103,7 +104,7 @@ func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err = convertUnicode(&item)
if err != nil {
return nil, err
logger.Error(err, "convert unicode: %s, err: %s", item, err)
}
if item.Field == "iteration_id" {
// some users' tapd will not return iteration_id_from/iteration_id_to
Expand Down
5 changes: 3 additions & 2 deletions backend/plugins/tapd/tasks/task_changelog_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var ExtractTaskChangelogMeta = plugin.SubTaskMeta{

func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error {
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_TASK_CHANGELOG_TABLE)
logger := taskCtx.GetLogger()
extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
Expand Down Expand Up @@ -92,7 +93,7 @@ func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err = convertUnicode(&item)
if err != nil {
return nil, err
logger.Error(err, "convert unicode: %s, err: %s", item, err)
}
default:
item.ConnectionId = data.Options.ConnectionId
Expand All @@ -103,7 +104,7 @@ func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error {
}
err = convertUnicode(&item)
if err != nil {
return nil, err
logger.Error(err, "convert unicode: %s, err: %s", item, err)
}
if item.Field == "iteration_id" {
iterationFrom, iterationTo, err := parseIterationChangelog(taskCtx, item.ValueBeforeParsed, item.ValueAfterParsed)
Expand Down

0 comments on commit ded45ae

Please sign in to comment.