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.
This commit is contained in:
kolaente 2026-03-04 16:52:07 +01:00
parent 6da0f68562
commit e07eeed211
1 changed files with 3 additions and 1 deletions

View File

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