1
0

feat(migration): use new structure for migration

This commit is contained in:
kolaente
2022-12-29 18:11:15 +01:00
parent fef253312c
commit 386e218b95
8 changed files with 44 additions and 44 deletions

View File

@ -74,12 +74,12 @@ func (date *tickTickTime) UnmarshalCSV(csv string) (err error) {
return err
}
func convertTickTickToVikunja(tasks []*tickTickTask) (result []*models.NamespaceWithProjectsAndTasks) {
namespace := &models.NamespaceWithProjectsAndTasks{
Namespace: models.Namespace{
func convertTickTickToVikunja(tasks []*tickTickTask) (result []*models.ProjectWithTasksAndBuckets) {
parent := &models.ProjectWithTasksAndBuckets{
Project: models.Project{
Title: "Migrated from TickTick",
},
Projects: []*models.ProjectWithTasksAndBuckets{},
ChildProjects: []*models.ProjectWithTasksAndBuckets{},
}
projects := make(map[string]*models.ProjectWithTasksAndBuckets)
@ -134,14 +134,14 @@ func convertTickTickToVikunja(tasks []*tickTickTask) (result []*models.Namespace
}
for _, l := range projects {
namespace.Projects = append(namespace.Projects, l)
parent.ChildProjects = append(parent.ChildProjects, l)
}
sort.Slice(namespace.Projects, func(i, j int) bool {
return namespace.Projects[i].Title < namespace.Projects[j].Title
sort.Slice(parent.ChildProjects, func(i, j int) bool {
return parent.ChildProjects[i].Title < parent.ChildProjects[j].Title
})
return []*models.NamespaceWithProjectsAndTasks{namespace}
return []*models.ProjectWithTasksAndBuckets{parent}
}
// Name is used to get the name of the ticktick migration - we're using the docs here to annotate the status route.