Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Allow to find task by a list of status

天舟f2c609a9436e
diff --git a/api/task.go b/api/task.go
index df94c930c8..2172876fab 100644
--- a/api/task.go
+++ b/api/task.go
@@ -8,6 +8,7 @@ import (
"github.com/bytebase/bytebase/plugin/db"
)
+// These are special onboarding tasks for demo purpose when bootstraping the workspace.
const ONBOARDING_TASK_ID1 = 101
const ONBOARDING_TASK_ID2 = 102
@@ -149,7 +150,7 @@ type TaskFind struct {
StageId *int
// Domain specific fields
- Status *TaskStatus `jsonapi:"attr,status"`
+ StatusList *[]TaskStatus
}
func (find *TaskFind) String() string {
diff --git a/server/task_scheduler.go b/server/task_scheduler.go
index 1fb4fe2699..2b5a34b40a 100644
--- a/server/task_scheduler.go
+++ b/server/task_scheduler.go
@@ -75,9 +75,9 @@ func (s *TaskScheduler) Run() error {
}
// Inspect all running tasks
- taskStatus := api.TaskRunning
+ taskStatusList := []api.TaskStatus{api.TaskRunning}
taskFind := &api.TaskFind{
- Status: &taskStatus,
+ StatusList: &taskStatusList,
}
taskList, err := s.server.TaskService.FindTaskList(context.Background(), taskFind)
if err != nil {
diff --git a/store/task.go b/store/task.go
index a1e135ec54..b73eeef659 100644
--- a/store/task.go
+++ b/store/task.go
@@ -219,8 +219,13 @@ func (s *TaskService) findTaskList(ctx context.Context, tx *Tx, find *api.TaskFi
if v := find.StageId; v != nil {
where, args = append(where, "stage_id = ?"), append(args, *v)
}
- if v := find.Status; v != nil {
- where, args = append(where, "`status` = ?"), append(args, *v)
+ if v := find.StatusList; v != nil {
+ list := []string{}
+ for _, status := range *v {
+ list = append(list, "?")
+ args = append(args, status)
+ }
+ where = append(where, fmt.Sprintf("`status` in (%s)", strings.Join(list, ",")))
}
rows, err := tx.QueryContext(ctx, `