From ce0d5a9b323e2d90ce0719be35ad5e99df530097 Mon Sep 17 00:00:00 2001 From: tzwang Date: Fri, 17 May 2024 19:43:25 +0800 Subject: [PATCH] fix db bugs Former-commit-id: 55a997bc7669f4b207da153a3fdd1cb3b1b2935d --- api/internal/logic/core/pagelisttasklogic.go | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/api/internal/logic/core/pagelisttasklogic.go b/api/internal/logic/core/pagelisttasklogic.go index abcbde00..f2f6d9e8 100644 --- a/api/internal/logic/core/pagelisttasklogic.go +++ b/api/internal/logic/core/pagelisttasklogic.go @@ -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)