From e07eeed21156ab2bdc6c02aceede9cbc91468a28 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 4 Mar 2026 16:52:07 +0100 Subject: [PATCH] refactor: batch label inserts during task duplication Collect all LabelTask records in the loop and insert them in a single database call instead of inserting one at a time. --- pkg/models/task_duplicate.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/models/task_duplicate.go b/pkg/models/task_duplicate.go index 064446add..669c5196d 100644 --- a/pkg/models/task_duplicate.go +++ b/pkg/models/task_duplicate.go @@ -101,7 +101,9 @@ func (td *TaskDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) { for _, lt := range labelTasks { lt.ID = 0 lt.TaskID = newTask.ID - if _, err := s.Insert(lt); err != nil { + } + if len(labelTasks) > 0 { + if _, err := s.Insert(&labelTasks); err != nil { return err } }