From 49a790fdad8e0aab9213462a916ca53b9bd16707 Mon Sep 17 00:00:00 2001 From: Erwan Martin Date: Sun, 17 Sep 2023 18:42:16 +0200 Subject: [PATCH] fix(docs): explain why we use NoAutoTime(). Add a comment explaining why we use NoAutoTime() when synchronizing the positions of tasks in a bucket/project. --- pkg/models/tasks.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index e8d1abb3f2..61242b9694 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -1081,6 +1081,10 @@ func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error) currentPosition := maxPosition / float64(len(allTasks)) * (float64(i + 1)) + // Here we use "NoAutoTime() to prevent the ORM from updating column "updated" automatically. + // Otherwise, this signals to CalDAV clients that the task has changed, which is not the case. + // Consequence: when synchronizing a list of tasks, the first one immediately changes the date of all the + // following ones from the same batch, which are then unable to be updated. _, err = s.Cols("kanban_position"). Where("id = ?", task.ID). NoAutoTime(). @@ -1110,6 +1114,10 @@ func recalculateTaskPositions(s *xorm.Session, projectID int64) (err error) { currentPosition := maxPosition / float64(len(allTasks)) * (float64(i + 1)) + // Here we use "NoAutoTime() to prevent the ORM from updating column "updated" automatically. + // Otherwise, this signals to CalDAV clients that the task has changed, which is not the case. + // Consequence: when synchronizing a list of tasks, the first one immediately changes the date of all the + // following ones from the same batch, which are then unable to be updated. _, err = s.Cols("position"). Where("id = ?", task.ID). NoAutoTime().