Skip to content

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

feat: issue search filter by task types (#8332)

p0ny2cdf1aa0dc4a
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 5c77c849c0..5c114f2d1d 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -347,11 +347,20 @@ func (s *IssueService) SearchIssues(ctx context.Context, request *v1pb.SearchIss
if spec.operator != comparatorTypeEqual {
return nil, status.Errorf(codes.InvalidArgument, `only support "=" operation for "level" filter`)
}
- // TODO(p0ny): fix it with the right type.
- if spec.value == "DDL" || spec.value == "DML" {
- issueFind.TypeList = append(issueFind.TypeList, api.IssueDatabaseGeneral)
- } else {
- return nil, status.Errorf(codes.InvalidArgument, `unknown value "%s"`, spec.value)
+ switch spec.value {
+ case "DDL":
+ issueFind.TaskTypes = &[]api.TaskType{
+ api.TaskDatabaseSchemaUpdate,
+ api.TaskDatabaseSchemaUpdateSDL,
+ api.TaskDatabaseSchemaUpdateGhostSync,
+ api.TaskDatabaseSchemaUpdateGhostCutover,
+ }
+ case "DML":
+ issueFind.TaskTypes = &[]api.TaskType{
+ api.TaskDatabaseDataUpdate,
+ }
+ default:
+ return nil, status.Errorf(codes.InvalidArgument, `unknown value %q`, spec.value)
}
case "instance":
if spec.operator != comparatorTypeEqual {
diff --git a/backend/store/issue.go b/backend/store/issue.go
index bf2394a23d..a39a49ce70 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -405,15 +405,11 @@ type FindIssueMessage struct {
CreatedTsAfter *int64
StatusList []api.IssueStatus
- TypeList []api.IssueType
- // If specified, only find issues whose ID is smaller that SinceID.
- SinceID *int
+ TaskTypes *[]api.TaskType
// If specified, then it will only fetch "Limit" most recently updated issues
Limit *int
Offset *int
- Stripped bool
-
Query *string
}
@@ -686,14 +682,12 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
if v := find.PlanUID; v != nil {
where, args = append(where, fmt.Sprintf("issue.plan_id = $%d", len(args)+1)), append(args, *v)
}
-
if v := find.ProjectResourceID; v != nil {
where, args = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM project WHERE project.id = issue.project_id AND project.resource_id = $%d)", len(args)+1)), append(args, *v)
}
if v := find.InstanceResourceID; v != nil {
where, args = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM task LEFT JOIN instance ON instance.id = task.instance_id WHERE task.pipeline_id = issue.pipeline_id AND instance.resource_id = $%d)", len(args)+1)), append(args, *v)
}
-
if v := find.PrincipalID; v != nil {
if find.CreatorID != nil || find.AssigneeID != nil || find.SubscriberID != nil {
return nil, &common.Error{Code: common.Invalid, Err: errors.New("principal_id cannot be used with creator_id, assignee_id, or subscriber_id")}
@@ -718,9 +712,6 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
if v := find.SubscriberID; v != nil {
where, args = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM issue_subscriber WHERE issue_subscriber.issue_id = issue.id AND issue_subscriber.subscriber_id = $%d)", len(args)+1)), append(args, *v)
}
- if v := find.SinceID; v != nil {
- where, args = append(where, fmt.Sprintf("issue.id <= $%d", len(args)+1)), append(args, *v)
- }
if v := find.Query; v != nil && *v != "" {
if tsQuery := getTsQuery(*v); tsQuery != "" {
from += fmt.Sprintf(`, CAST($%d AS tsquery) AS query`, len(args)+1)
@@ -737,13 +728,9 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
}
where = append(where, fmt.Sprintf("issue.status IN (%s)", strings.Join(list, ", ")))
}
- if len(find.TypeList) != 0 {
- var list []string
- for _, issueType := range find.TypeList {
- list = append(list, fmt.Sprintf("$%d", len(args)+1))
- args = append(args, issueType)
- }
- where = append(where, fmt.Sprintf("issue.type IN (%s)", strings.Join(list, ", ")))
+ if v := find.TaskTypes; v != nil {
+ where = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM task WHERE task.pipeline_id = issue.pipeline_id AND task.type = ANY($%d))", len(args)+1))
+ args = append(args, *v)
}
limitOffsetClause := ""
if v := find.Limit; v != nil {