调整任务进度跟踪器, 改为从数据库获取执行进度:
提供仓库层api
This commit is contained in:
@@ -31,6 +31,9 @@ type PendingTaskRepository interface {
|
||||
RequeueTask(originalPendingTask *models.PendingTask) error
|
||||
// FindPendingTasksByTaskLogIDs 根据 TaskExecutionLogID 列表查找对应的待执行任务
|
||||
FindPendingTasksByTaskLogIDs(taskLogIDs []uint) ([]models.PendingTask, error)
|
||||
|
||||
// DeletePendingTasksByPlanLogID 删除与指定计划执行日志ID相关的所有待执行任务
|
||||
DeletePendingTasksByPlanLogID(planLogID uint) error
|
||||
}
|
||||
|
||||
// gormPendingTaskRepository 是使用 GORM 的具体实现。
|
||||
@@ -164,3 +167,12 @@ func (r *gormPendingTaskRepository) FindPendingTasksByTaskLogIDs(taskLogIDs []ui
|
||||
err := r.db.Where("task_execution_log_id IN ?", taskLogIDs).Find(&pendingTasks).Error
|
||||
return pendingTasks, err
|
||||
}
|
||||
|
||||
// DeletePendingTasksByPlanLogID 删除与指定计划执行日志ID相关的所有待执行任务
|
||||
func (r *gormPendingTaskRepository) DeletePendingTasksByPlanLogID(planLogID uint) error {
|
||||
// 使用子查询找到所有与 planLogID 相关的 task_execution_log_id
|
||||
subQuery := r.db.Model(&models.TaskExecutionLog{}).Select("id").Where("plan_execution_log_id = ?", planLogID)
|
||||
|
||||
// 使用子查询的结果来删除待执行任务
|
||||
return r.db.Where("task_execution_log_id IN (?)", subQuery).Delete(&models.PendingTask{}).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user