Add copying task relations

This commit is contained in:
kolaente 2020-06-29 22:35:28 +02:00
parent 01d1c8f6e9
commit fac0046f12
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 20 additions and 2 deletions

View File

@ -84,7 +84,7 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
}
taskMap := make(map[int64]int64)
// Create + update all tasks
// Create + update all tasks (includes reminders)
oldTaskIDs := make([]int64, len(tasks))
for _, t := range tasks {
oldID := t.ID
@ -171,7 +171,25 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
}
// Relations in that list
// Reminders
// Low-Effort: Only copy those relations which are between tasks in the same list
// because we can do that without a lot of hassle
relations := []*TaskRelation{}
err = x.In("task_id", oldTaskIDs).Find(relations)
if err != nil {
return
}
for _, r := range relations {
otherTaskID, exists := taskMap[r.OtherTaskID]
if !exists {
continue
}
r.OtherTaskID = otherTaskID
r.TaskID = taskMap[r.TaskID]
if _, err := x.Insert(r); err != nil {
return err
}
}
// Background files + unsplash info
// Rights / Shares