Fix creating related tasks
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2020-02-18 22:31:53 +01:00
parent 2d137e3b7d
commit 09eaf16d87
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 10 additions and 5 deletions

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
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)
}
}