fix db bugs

Former-commit-id: 55a997bc7669f4b207da153a3fdd1cb3b1b2935d
This commit is contained in:
tzwang 2024-05-17 19:43:25 +08:00
parent 5ecf478439
commit ce0d5a9b32
1 changed files with 20 additions and 2 deletions

View File

@ -80,8 +80,6 @@ func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.Pa
for _, ch := range chs {
select {
case <-ch:
case <-time.After(2 * time.Second):
return
}
}
return
@ -107,6 +105,26 @@ func (l *PageListTaskLogic) updateTaskStatus(tasks []*types.TaskModel, ch chan<-
continue
}
if len(aiTask) == 1 {
task.Status = aiTask[0].Status
task.StartTime = aiTask[0].StartTime
task.EndTime = aiTask[0].EndTime
tx = l.svcCtx.DbEngin.Model(&types.TaskModel{}).Table("task")
tx = tx.Where("deleted_at is null")
tx = tx.Updates(task)
if tx.Error != nil {
logx.Errorf(tx.Error.Error())
return
}
continue
}
for i := len(aiTask) - 1; i >= 0; i-- {
if aiTask[i].StartTime == "" {
aiTask = append(aiTask[:i], aiTask[i+1:]...)
}
}
start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local)
end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local)