Merge pull request 'updated deployinstance logics' (#298) from tzwang/pcm-coordinator:master into master

Former-commit-id: f78a7e526fed5a6374683a7a42d193f419fdf583
This commit is contained in:
tzwang 2024-08-30 17:46:49 +08:00
commit d854e8ca23
1 changed files with 15 additions and 6 deletions

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:]...)
}
}
}