diff --git a/pkg/migrate/main.go b/pkg/migrate/main.go index 704ec9cba..d0f18e012 100644 --- a/pkg/migrate/main.go +++ b/pkg/migrate/main.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "encoding/csv" - "errors" "fmt" "io" "strconv" @@ -35,13 +34,14 @@ type ( ) func Migrate(mg []types.Migrateable, ns *cct.Namespace, ctx context.Context) error { + var preProcW []string + mig := &Migrator{} svcMod := service.DefaultModule.With(ctx) var err error // 1. migrate all the users, so we can reference then accross the entire system - start := time.Now() var mgUsr *types.Migrateable for _, m := range mg { if m.Name == userModHandle { @@ -80,12 +80,11 @@ func Migrate(mg []types.Migrateable, ns *cct.Namespace, ctx context.Context) err } for _, m := range ss { - fmt.Printf("mg.processing > %s\n", m.Name) - // 2.1 load module mod, err := svcMod.FindByHandle(ns.ID, m.Name) if err != nil { - return err + preProcW = append(preProcW, err.Error()+" "+m.Name) + continue } // 2.2 get header fields @@ -119,23 +118,26 @@ func Migrate(mg []types.Migrateable, ns *cct.Namespace, ctx context.Context) err if f.Kind == "Record" { refMod := f.Options["moduleID"] if refMod == nil { - return errors.New("moduleField.record.missingRef") + preProcW = append(preProcW, "moduleField.record.missingRef"+" "+m.Name+" "+f.Name) + continue } modID, ok := refMod.(string) if !ok { - return errors.New("moduleField.record.invalidRefFormat") + preProcW = append(preProcW, "moduleField.record.invalidRefFormat"+" "+m.Name+" "+f.Name) + continue } - fmt.Printf("mg.node.link > %s [%s]\n", f.Name, modID) vv, err := strconv.ParseUint(modID, 10, 64) if err != nil { - return err + preProcW = append(preProcW, err.Error()) + continue } mm, err := svcMod.FindByID(ns.ID, vv) if err != nil { - return err + preProcW = append(preProcW, err.Error()+" "+m.Name+" "+f.Name+" "+modID) + continue } nn := &types.Node{ @@ -149,12 +151,9 @@ func Migrate(mg []types.Migrateable, ns *cct.Namespace, ctx context.Context) err n.LinkAdd(nn) } } - - fmt.Printf("mg.processed > %s\n\n\n", m.Name) } } - fmt.Printf("graph.remove.cycles\n") mig.MakeAcyclic() for _, n := range mig.nodes { @@ -164,25 +163,14 @@ func Migrate(mg []types.Migrateable, ns *cct.Namespace, ctx context.Context) err } } - graphT := time.Since(start) - fmt.Printf("migration.prepared\n") fmt.Printf("no. of nodes %d\n", len(mig.nodes)) fmt.Printf("no. of entry points %d\n", len(mig.Leafs)) - fmt.Printf("\n\nmigrator.migrating\n") - - start = time.Now() - err = mig.Migrate(ctx, uMap) if err != nil { return err } - migT := time.Since(start) - start = time.Now() - - fmt.Printf("\n\nmigrator.migrating.finished\n") - fmt.Printf("time;\n* users: %s,\n* graph: %s,\n* migration: %s", usrT, graphT, migT) return nil } @@ -276,6 +264,11 @@ func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error { m.Leafs = nl } + fmt.Print("\n\n\n") + fmt.Println("(⌐■_■)") + fmt.Println("(-•_•)>⌐■-■") + fmt.Println("(•_•)") + return nil }) } diff --git a/pkg/migrate/types/node.go b/pkg/migrate/types/node.go index 7b1ba149e..3eaefd508 100644 --- a/pkg/migrate/types/node.go +++ b/pkg/migrate/types/node.go @@ -80,14 +80,12 @@ func (n *Node) Migrate(repoRecord repository.RecordRepository, users map[string] defer wg.Done() defer bar.Add(1) - fmt.Printf("node.migrate > %s\n", n.Stringify()) var err error mapping := make(Map) if n.Reader != nil { // if records exist (from spliced node); correct refs if !n.spliced && n.records != nil && len(n.records) > 0 { - fmt.Printf("node.refs.update\n") // we can just reuse the mapping object, since it will remain the same mapping = n.mapping[fmt.Sprint(n.Module.ID)] @@ -99,9 +97,7 @@ func (n *Node) Migrate(repoRecord repository.RecordRepository, users map[string] } return } - fmt.Printf("node.refs.update.done\n") } else { - fmt.Printf("node.migrate.source\n") mapping, err = importNodeSource(n, users, repoRecord) if err != nil { ch <- PostProc{ @@ -110,7 +106,6 @@ func (n *Node) Migrate(repoRecord repository.RecordRepository, users map[string] } return } - fmt.Printf("node.migrate.source.done\n") } }