From ca5fa2de110b69c983a30c39564c3591274dd240 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Thu, 30 May 2024 20:11:04 +0800 Subject: [PATCH] fix: task obj_name rename to obj_type (#20410) Co-authored-by: Qiu Jian --- pkg/apis/tasks.go | 3 ++- pkg/cloudcommon/db/taskman/tasks.go | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/apis/tasks.go b/pkg/apis/tasks.go index 8abc374d243..b4cf7f96b9b 100644 --- a/pkg/apis/tasks.go +++ b/pkg/apis/tasks.go @@ -27,7 +27,8 @@ type TaskListInput struct { Id []string `json:"id" help:"id filter"` ObjId []string `json:"obj_id" help:"object id filter"` - ObjName []string `json:"obj_name" help:"object type (in singular form) filter"` + ObjType []string `json:"obj_type" help:"object type (in singular form) filter"` + ObjName []string `json:"obj_name" help:"object name filter"` TaskName []string `json:"task_name" help:"task name filter"` IsMulti *bool `json:"is_multi" negative:"is_single" help:"is multi task"` IsComplete *bool `json:"is_complete" negative:"not_complete" help:"is task completed, either fail or complete"` diff --git a/pkg/cloudcommon/db/taskman/tasks.go b/pkg/cloudcommon/db/taskman/tasks.go index 15e1b177ce1..5c735113c71 100644 --- a/pkg/cloudcommon/db/taskman/tasks.go +++ b/pkg/cloudcommon/db/taskman/tasks.go @@ -983,7 +983,7 @@ func (manager *STaskManager) QueryTasksOfObject(obj db.IStandaloneModel, since t subq1 := manager.Query() { subq1 = subq1.Equals("obj_id", obj.GetId()) - subq1 = subq1.Equals("obj_name", obj.Keyword()) + subq1 = subq1.Equals("obj_type", obj.Keyword()) if !since.IsZero() { subq1 = subq1.GE("created_at", since) } @@ -1006,7 +1006,7 @@ func (manager *STaskManager) QueryTasksOfObject(obj db.IStandaloneModel, since t sqlchemy.Equals(taskObjs.Field("obj_id"), obj.GetId()), )) subq2 = subq2.Filter(sqlchemy.Equals(subq2.Field("obj_id"), MULTI_OBJECTS_ID)) - subq2 = subq2.Filter(sqlchemy.Equals(subq2.Field("obj_name"), obj.Keyword())) + subq2 = subq2.Filter(sqlchemy.Equals(subq2.Field("obj_type"), obj.Keyword())) if !since.IsZero() { subq2 = subq2.Filter(sqlchemy.GE(subq2.Field("created_at"), since)) } @@ -1087,7 +1087,11 @@ func (manager *STaskManager) ListItemFilter( } if len(input.ObjName) > 0 { - q = q.In("obj_name", input.ObjName) + q = q.In("object", input.ObjName) + } + + if len(input.ObjType) > 0 { + q = q.In("obj_type", input.ObjType) } if len(input.TaskName) > 0 {