Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/tapd/models/story_changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type TapdStoryChangelogItemRes struct {
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
Expand Down
2 changes: 2 additions & 0 deletions plugins/tapd/models/task_changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type TapdTaskChangelogItemRes struct {
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
Expand Down
33 changes: 25 additions & 8 deletions plugins/tapd/tasks/story_changelog_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,39 @@ func ExtractStoryChangelog(taskCtx core.SubTaskContext) error {
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
}
}
switch valueAfterMap.(type) {
case map[string]interface{}:
valueBeforeMap := map[string]string{}
err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap)
if err != nil {
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{}:
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
Expand Down
34 changes: 25 additions & 9 deletions plugins/tapd/tasks/task_changelog_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,39 @@ func ExtractTaskChangelog(taskCtx core.SubTaskContext) error {
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
}
}
switch valueAfterMap.(type) {
case map[string]interface{}:
valueBeforeMap := map[string]string{}
err = json.Unmarshal(fc.ValueBeforeParsed, &valueBeforeMap)
if err != nil {
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{}:
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
Expand Down