fix(tapd): modify changelo
diff --git a/plugins/tapd/models/story_changelog.go b/plugins/tapd/models/story_changelog.go
index 28f58a3..1a04c6f 100644
--- a/plugins/tapd/models/story_changelog.go
+++ b/plugins/tapd/models/story_changelog.go
@@ -45,6 +45,8 @@
Field string `json:"field" gorm:"primaryKey;type:varchar(255)"`
ValueBeforeParsed json.RawMessage `json:"value_before_parsed"`
ValueAfterParsed json.RawMessage `json:"value_after_parsed"`
+ ValueBefore json.RawMessage `json:"value_before"`
+ ValueAfter json.RawMessage `json:"value_after"`
IterationIdFrom uint64
IterationIdTo uint64
common.NoPKModel
diff --git a/plugins/tapd/models/task_changelog.go b/plugins/tapd/models/task_changelog.go
index 5177c85..29df87e 100644
--- a/plugins/tapd/models/task_changelog.go
+++ b/plugins/tapd/models/task_changelog.go
@@ -58,6 +58,8 @@
Field string `json:"field" gorm:"primaryKey;type:varchar(255)"`
ValueBeforeParsed json.RawMessage `json:"value_before_parsed"`
ValueAfterParsed json.RawMessage `json:"value_after_parsed"`
+ ValueBefore json.RawMessage `json:"value_before"`
+ ValueAfter json.RawMessage `json:"value_after"`
IterationIdFrom uint64
IterationIdTo uint64
common.NoPKModel
diff --git a/plugins/tapd/tasks/story_changelog_extractor.go b/plugins/tapd/tasks/story_changelog_extractor.go
index 5fd17cd..64ce088 100644
--- a/plugins/tapd/tasks/story_changelog_extractor.go
+++ b/plugins/tapd/tasks/story_changelog_extractor.go
@@ -56,22 +56,39 @@
for _, fc := range storyChangelog.FieldChanges {
var item models.TapdStoryChangelogItem
var valueAfterMap interface{}
- if err = json.Unmarshal(fc.ValueAfterParsed, &valueAfterMap); err != nil {
- return nil, err
+ var valueBeforeMap interface{}
+ if fc.ValueAfterParsed == nil {
+ if err = json.Unmarshal(fc.ValueAfter, &valueAfterMap); err != nil {
+ return nil, err
+ }
+ } else {
+ if err = json.Unmarshal(fc.ValueAfterParsed, &valueAfterMap); err != nil {
+ return nil, err
+ }
+ }
+ if fc.ValueBeforeParsed == nil {
+ if err = json.Unmarshal(fc.ValueBefore, &valueBeforeMap); err != nil {
+ return nil, err
+ }
+ } else {
+ if err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap); err != nil {
+ return nil, err
+ }
}
switch valueAfterMap.(type) {
case map[string]interface{}:
- valueBeforeMap := map[string]string{}
- err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap)
- if err != nil {
- return nil, err
- }
for k, v := range valueAfterMap.(map[string]interface{}) {
item.ConnectionId = data.Options.ConnectionId
item.ChangelogId = storyChangelog.Id
item.Field = k
item.ValueAfterParsed = v.(string)
- item.ValueBeforeParsed = valueBeforeMap[k]
+ switch valueBeforeMap.(type) {
+ case map[string]interface{}:
+ item.ValueBeforeParsed = valueBeforeMap.(map[string]interface{})[k].(string)
+ default:
+ item.ValueBeforeParsed = valueBeforeMap.(string)
+ }
+ results = append(results, &item)
}
default:
item.ConnectionId = data.Options.ConnectionId
diff --git a/plugins/tapd/tasks/task_changelog_extractor.go b/plugins/tapd/tasks/task_changelog_extractor.go
index a081d2c..a6d381e 100644
--- a/plugins/tapd/tasks/task_changelog_extractor.go
+++ b/plugins/tapd/tasks/task_changelog_extractor.go
@@ -56,23 +56,39 @@
for _, fc := range taskChangelog.FieldChanges {
var item models.TapdTaskChangelogItem
var valueAfterMap interface{}
- if err = json.Unmarshal(fc.ValueAfterParsed, &valueAfterMap); err != nil {
- return nil, err
+ var valueBeforeMap interface{}
+ if fc.ValueAfterParsed == nil {
+ if err = json.Unmarshal(fc.ValueAfter, &valueAfterMap); err != nil {
+ return nil, err
+ }
+ } else {
+ if err = json.Unmarshal(fc.ValueAfterParsed, &valueAfterMap); err != nil {
+ return nil, err
+ }
+ }
+ if fc.ValueBeforeParsed == nil {
+ if err = json.Unmarshal(fc.ValueBefore, &valueBeforeMap); err != nil {
+ return nil, err
+ }
+ } else {
+ if err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap); err != nil {
+ return nil, err
+ }
}
switch valueAfterMap.(type) {
case map[string]interface{}:
- valueBeforeMap := map[string]string{}
- err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap)
- if err != nil {
- return nil, err
- }
for k, v := range valueAfterMap.(map[string]interface{}) {
item.ConnectionId = data.Options.ConnectionId
item.ChangelogId = taskChangelog.Id
item.Field = k
item.ValueAfterParsed = v.(string)
- item.ValueBeforeParsed = valueBeforeMap[k]
- results = append(results, item)
+ switch valueBeforeMap.(type) {
+ case map[string]interface{}:
+ item.ValueBeforeParsed = valueBeforeMap.(map[string]interface{})[k].(string)
+ default:
+ item.ValueBeforeParsed = valueBeforeMap.(string)
+ }
+ results = append(results, &item)
}
default:
item.ConnectionId = data.Options.ConnectionId