Skip to content

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

feat: ListIssues filter by task db (#8374)

p0ny052ac0531700
diff --git a/backend/store/issue.go b/backend/store/issue.go
index a39a49ce70..ef2e45671f 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -389,11 +389,10 @@ type UpdateIssueMessage struct {
// FindIssueMessage is the message to find issues.
type FindIssueMessage struct {
- UID *int
- ProjectResourceID *string
- InstanceResourceID *string
- PlanUID *int64
- PipelineID *int
+ UID *int
+ ProjectResourceID *string
+ PlanUID *int64
+ PipelineID *int
// Find issues where principalID is either creator, assignee or subscriber.
PrincipalID *int
// To support pagination, we add into creator, assignee and subscriber.
@@ -406,6 +405,10 @@ type FindIssueMessage struct {
StatusList []api.IssueStatus
TaskTypes *[]api.TaskType
+ // Any of the task in the issue changes the instance with InstanceResourceID.
+ InstanceResourceID *string
+ // Any of the task in the issue changes the database with DatabaseUID.
+ DatabaseUID *int
// If specified, then it will only fetch "Limit" most recently updated issues
Limit *int
Offset *int
@@ -688,6 +691,9 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
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.DatabaseUID; v != nil {
+ where, args = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM task WHERE task.pipeline_id = issue.pipeline_id AND task.database_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")}