Browse Source

updated getdeploytaskbytype logic

Former-commit-id: 518ccaa4b1
pull/298/head
tzwang 1 year ago
parent
commit
9851e66a0e
1 changed files with 15 additions and 6 deletions
  1. +15
    -6
      internal/logic/inference/getdeploytasksbytypelogic.go

+ 15
- 6
internal/logic/inference/getdeploytasksbytypelogic.go View File

@@ -47,7 +47,7 @@ func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTas
return nil, err
}
if len(inslist) == 0 {
removeItem(listcopy, task.Id)
removeItem(&listcopy, task.Id)
}
var count int
for _, ins := range inslist {
@@ -59,17 +59,26 @@ func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTas
continue
}

removeItem(listcopy, task.Id)
removeItem(&listcopy, task.Id)
}

resp.List = listcopy
return resp, nil
}

func removeItem(items []*models.AiDeployInstanceTask, id int64) {
for i := len(items) - 1; i >= 0; i-- {
if items[i].Id == id {
items = append(items[:i], items[i+1:]...)
func removeItem(items *[]*models.AiDeployInstanceTask, id int64) {
if len(*items) == 0 {
return
}
if len(*items) == 1 {
if (*items)[0].Id == id {
(*items) = nil
return
}
}
for i := len(*items) - 1; i >= 0; i-- {
if (*items)[i].Id == id {
*items = append((*items)[:i], (*items)[i+1:]...)
}
}
}

Loading…
Cancel
Save