Skip to content

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

Use both PipelineID and StageID to find task to leverage index

天舟f9310ac6279f
diff --git a/server/stage.go b/server/stage.go
index f3e3eabc06..8c1ecaf95c 100644
--- a/server/stage.go
+++ b/server/stage.go
@@ -41,7 +41,7 @@ func (s *Server) ComposeStageRelationship(ctx context.Context, stage *api.Stage)
return err
}
- stage.TaskList, err = s.ComposeTaskListByStageId(context.Background(), stage.ID)
+ stage.TaskList, err = s.ComposeTaskListByPipelineAndStageId(context.Background(), stage.PipelineId, stage.ID)
if err != nil {
return err
}
diff --git a/server/task.go b/server/task.go
index dc7ec370d6..10fcfbdf78 100644
--- a/server/task.go
+++ b/server/task.go
@@ -71,9 +71,10 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {
})
}
-func (s *Server) ComposeTaskListByStageId(ctx context.Context, stageId int) ([]*api.Task, error) {
+func (s *Server) ComposeTaskListByPipelineAndStageId(ctx context.Context, pipelineId int, stageId int) ([]*api.Task, error) {
taskFind := &api.TaskFind{
- StageId: &stageId,
+ PipelineId: &pipelineId,
+ StageId: &stageId,
}
taskList, err := s.TaskService.FindTaskList(context.Background(), taskFind)
if err != nil {