Add copying task relations
This commit is contained in:
parent
01d1c8f6e9
commit
fac0046f12
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue