1
0

Todoist Migration (#566)

Add swagger docs + fix lint

Add parsing logic + fix fixtures

Fix test init

Add logging to creating labels and debug logs

Add creating labels when migrating

Finish test fixtures

Started adding fixtures for testing

Add method and test structures to convert todoist to vikunja

Add basic structure to migrate everything

Add all structs for todoist api

Add docs for config options

Add routes for todoist migrator

Add api token exchange

Add basic structure for todoist migration

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/566
This commit is contained in:
konrad
2020-05-23 20:50:54 +00:00
parent 292c815000
commit e89e6d47d4
9 changed files with 1123 additions and 1 deletions

View File

@ -30,6 +30,8 @@ func InsertFromStructure(str []*models.NamespaceWithLists, user *user.User) (err
log.Debugf("[creating structure] Creating %d namespaces", len(str))
labels := make(map[string]*models.Label)
// Create all namespaces
for _, n := range str {
err = n.Create(user)
@ -118,6 +120,34 @@ func InsertFromStructure(str []*models.NamespaceWithLists, user *user.User) (err
log.Debugf("[creating structure] Created new attachment %d", a.ID)
}
}
// Create all labels
for _, label := range t.Labels {
// Check if we already have a label with that name + color combination and use it
// If not, create one and save it for later
var lb *models.Label
var exists bool
lb, exists = labels[label.Title+label.HexColor]
if !exists {
err = label.Create(user)
if err != nil {
return err
}
log.Debugf("[creating structure] Created new label %d", label.ID)
labels[label.Title+label.HexColor] = label
lb = label
}
lt := &models.LabelTask{
LabelID: lb.ID,
TaskID: t.ID,
}
err = lt.Create(user)
if err != nil {
return err
}
log.Debugf("[creating structure] Associated task %d with label %d", t.ID, lb.ID)
}
}
}
}