mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-21 05:40:25 +08:00
节点任务查询时增加排除的任务类型
This commit is contained in:
@@ -311,20 +311,30 @@ func (this *NodeTaskDAO) FindAllDoingNodeIds(tx *dbs.Tx, role string) ([]int64,
|
||||
}
|
||||
|
||||
// ExistsDoingNodeTasks 检查是否有正在执行的任务
|
||||
func (this *NodeTaskDAO) ExistsDoingNodeTasks(tx *dbs.Tx, role string) (bool, error) {
|
||||
return this.Query(tx).
|
||||
func (this *NodeTaskDAO) ExistsDoingNodeTasks(tx *dbs.Tx, role string, excludeTypes []NodeTaskType) (bool, error) {
|
||||
var query = this.Query(tx).
|
||||
Attr("role", role).
|
||||
Where("(isDone=0 OR (isDone=1 AND isOk=0))").
|
||||
Gt("nodeId", 0).
|
||||
Exist()
|
||||
Gt("nodeId", 0)
|
||||
if len(excludeTypes) > 0 {
|
||||
for _, excludeType := range excludeTypes {
|
||||
query.Neq("type", excludeType)
|
||||
}
|
||||
}
|
||||
return query.Exist()
|
||||
}
|
||||
|
||||
// ExistsErrorNodeTasks 是否有错误的任务
|
||||
func (this *NodeTaskDAO) ExistsErrorNodeTasks(tx *dbs.Tx, role string) (bool, error) {
|
||||
return this.Query(tx).
|
||||
func (this *NodeTaskDAO) ExistsErrorNodeTasks(tx *dbs.Tx, role string, excludeTypes []NodeTaskType) (bool, error) {
|
||||
var query = this.Query(tx).
|
||||
Attr("role", role).
|
||||
Where("(isDone=1 AND isOk=0)").
|
||||
Exist()
|
||||
Where("(isDone=1 AND isOk=0)")
|
||||
if len(excludeTypes) > 0 {
|
||||
for _, excludeType := range excludeTypes {
|
||||
query.Neq("type", excludeType)
|
||||
}
|
||||
}
|
||||
return query.Exist()
|
||||
}
|
||||
|
||||
// DeleteNodeTask 删除任务
|
||||
|
||||
@@ -163,13 +163,13 @@ func (this *NodeTaskService) ExistsNodeTasks(ctx context.Context, req *pb.Exists
|
||||
var tx = this.NullTx()
|
||||
|
||||
// 是否有任务
|
||||
existTask, err := models.SharedNodeTaskDAO.ExistsDoingNodeTasks(tx, nodeconfigs.NodeRoleNode)
|
||||
existTask, err := models.SharedNodeTaskDAO.ExistsDoingNodeTasks(tx, nodeconfigs.NodeRoleNode, req.ExcludeTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 是否有错误
|
||||
existError, err := models.SharedNodeTaskDAO.ExistsErrorNodeTasks(tx, nodeconfigs.NodeRoleNode)
|
||||
existError, err := models.SharedNodeTaskDAO.ExistsErrorNodeTasks(tx, nodeconfigs.NodeRoleNode, req.ExcludeTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user