Skip to content

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

feat: add create_time filter to search issue service (#7821)

p0nyd515660d9b87
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 6f860b03fe..a61f710f33 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -178,6 +178,20 @@ func (s *IssueService) SearchIssues(ctx context.Context, request *v1pb.SearchIss
}
issueFind.StatusList = append(issueFind.StatusList, newStatus)
}
+ case "create_time_before":
+ t, err := time.Parse(time.RFC3339, spec.value)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, "failed to parse create_time_before %s, err: %v", spec.value, err)
+ }
+ ts := t.Unix()
+ issueFind.CreatedTsBefore = &ts
+ case "create_time_after":
+ t, err := time.Parse(time.RFC3339, spec.value)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, "failed to parse create_time_after %s, err: %v", spec.value, err)
+ }
+ ts := t.Unix()
+ issueFind.CreatedTsAfter = &ts
}
}
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 01933cfabf..ad6b7598a1 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -560,10 +560,12 @@ type FindIssueMessage struct {
PrincipalID *int
// To support pagination, we add into creator, assignee and subscriber.
// Only principleID or one of the following three fields can be set.
- CreatorID *int
- AssigneeID *int
- SubscriberID *int
- NeedAttention *bool
+ CreatorID *int
+ AssigneeID *int
+ SubscriberID *int
+ NeedAttention *bool
+ CreatedTsBefore *int64
+ CreatedTsAfter *int64
StatusList []api.IssueStatus
// If specified, only find issues whose ID is smaller that SinceID.
@@ -865,6 +867,12 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
if v := find.AssigneeID; v != nil {
where, args = append(where, fmt.Sprintf("issue.assignee_id = $%d", len(args)+1)), append(args, *v)
}
+ if v := find.CreatedTsBefore; v != nil {
+ where, args = append(where, fmt.Sprintf("issue.created_ts < $%d", len(args)+1)), append(args, *v)
+ }
+ if v := find.CreatedTsAfter; v != nil {
+ where, args = append(where, fmt.Sprintf("issue.created_ts > $%d", len(args)+1)), append(args, *v)
+ }
if v := find.NeedAttention; v != nil {
where, args = append(where, fmt.Sprintf("issue.assignee_need_attention = $%d", len(args)+1)), append(args, *v)
}