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:
parent
6da0f68562
commit
e07eeed211
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue