Fix inserting task structure with related tasks #142

Merged
konrad merged 4 commits from fix/migration-subtasks into master 2020-02-18 22:00:55 +00:00
1 changed files with 10 additions and 5 deletions
Showing only changes of commit 09eaf16d87 - Show all commits

View File

@ -65,13 +65,18 @@ func InsertFromStructure(str []*models.NamespaceWithLists, user *user.User) (err
log.Debugf("[creating structure] Created task %d", t.ID)
if len(t.RelatedTasks) > 0 {
log.Debugf("[creating structure] Creating %d related tasks", len(t.RelatedTasks))
log.Debugf("[creating structure] Creating %d related task kinds", len(t.RelatedTasks))
}
// Create all relation for each task
for kind, tasks := range t.RelatedTasks {
// First create the related tasks if they does not exist
if len(tasks) > 0 {
log.Debugf("[creating structure] Creating %d related tasks for kind %v", len(tasks), kind)
}
for _, rt := range tasks {
// First create the related tasks if they does not exist

does → do

does → do

Right, thanks!

Right, thanks!
if rt.ID == 0 {
rt.ListID = t.ListID
err = rt.Create(user)
@ -83,8 +88,8 @@ func InsertFromStructure(str []*models.NamespaceWithLists, user *user.User) (err
// Then create the relation
taskRel := &models.TaskRelation{
TaskID: rt.ID,
OtherTaskID: t.ID,
TaskID: t.ID,
OtherTaskID: rt.ID,
RelationKind: kind,
}
err = taskRel.Create(user)
@ -92,7 +97,7 @@ func InsertFromStructure(str []*models.NamespaceWithLists, user *user.User) (err
return
}
log.Debugf("[creating structure] Created task relation between task %d and %d with new ID %d", t.ID, rt.ID, taskRel.ID)
log.Debugf("[creating structure] Created task relation between task %d and %d", t.ID, rt.ID)
}
}