From eeae3dac24922bd794e230b735c0e5f428b4d4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Wed, 18 Mar 2020 17:39:54 +0100 Subject: [PATCH] Small data handling tweak --- pkg/migrate/types/node.go | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/pkg/migrate/types/node.go b/pkg/migrate/types/node.go index 1a4b50b36..793b12623 100644 --- a/pkg/migrate/types/node.go +++ b/pkg/migrate/types/node.go @@ -442,20 +442,29 @@ func importNodeSource(n *Node, users map[string]uint64, repo repository.RecordRe } if f.Options["moduleID"] != nil { - // spliced nodes should NOT manage their references - if !n.spliced && f != nil && f.Options["moduleID"] != nil { - ref, ok := f.Options["moduleID"].(string) - if !ok { - return nil, errors.New("moduleField.record.invalidRefFormat") - } + // spliced nodes should NOT manage their references + if !n.spliced { + ref, ok := f.Options["moduleID"].(string) + if !ok { + return nil, errors.New("moduleField.record.invalidRefFormat") + } - if n.mapping[ref] != nil { - if n.mapping[ref] != nil { - val = n.mapping[ref][val] + if mod, ok := n.mapping[ref]; ok { + if v, ok := mod[val]; ok { + val = v + } else { + continue + } + } else { + continue } } } else if f.Kind == "User" { - } + if u, ok := users[val]; ok { + val = fmt.Sprint(u) + } else { + continue + } } else { val = strings.Map(fixUtf, val) @@ -464,12 +473,10 @@ func importNodeSource(n *Node, users map[string]uint64, repo repository.RecordRe } } - if val != "" { - vals = append(vals, &types.RecordValue{ - Name: h, - Value: val, - }) - } + vals = append(vals, &types.RecordValue{ + Name: h, + Value: val, + }) } }