Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update issue search api (#7820)
ecmadao23995fab2e42
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex 66fd0ad6b1..6f860b03fe 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -133,12 +133,55 @@ func (s *IssueService) SearchIssues(ctx context.Context, request *v1pb.SearchIss}limitPlusOne := limit + 1- issues, err := s.store.ListIssueV2(ctx, &store.FindIssueMessage{+ issueFind := &store.FindIssueMessage{ProjectUID: projectUID,Query: &request.Query,Limit: &limitPlusOne,Offset: &offset,- })+ }++ filters, err := parseFilter(request.Filter)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }+ for _, spec := range filters {+ switch spec.key {+ case "principal":+ user, err := s.getUserByIdentifier(ctx, spec.value)+ if err != nil {+ return nil, err+ }+ issueFind.PrincipalID = &user.ID+ case "creator":+ user, err := s.getUserByIdentifier(ctx, spec.value)+ if err != nil {+ return nil, err+ }+ issueFind.AssigneeID = &user.ID+ case "assignee":+ user, err := s.getUserByIdentifier(ctx, spec.value)+ if err != nil {+ return nil, err+ }+ issueFind.AssigneeID = &user.ID+ case "subscriber":+ user, err := s.getUserByIdentifier(ctx, spec.value)+ if err != nil {+ return nil, err+ }+ issueFind.SubscriberID = &user.ID+ case "status":+ for _, raw := range strings.Split(spec.value, " | ") {+ newStatus, err := convertToAPIIssueStatus(v1pb.IssueStatus(v1pb.IssueStatus_value[raw]))+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "failed to convert to issue status, err: %v", err)+ }+ issueFind.StatusList = append(issueFind.StatusList, newStatus)+ }+ }+ }++ issues, err := s.store.ListIssueV2(ctx, issueFind)if err != nil {return nil, status.Errorf(codes.Internal, "failed to search issue, error: %v", err)}@@ -169,6 +212,24 @@ func (s *IssueService) SearchIssues(ctx context.Context, request *v1pb.SearchIss}, nil}+func (s *IssueService) getUserByIdentifier(ctx context.Context, identifier string) (*store.UserMessage, error) {+ email := strings.TrimPrefix(identifier, "users/")+ if email == "" {+ return nil, status.Errorf(codes.InvalidArgument, "invalid empty creator identifier")+ }+ user, err := s.store.GetUser(ctx, &store.FindUserMessage{+ Email: &email,+ ShowDeleted: true,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, `failed to find user "%s" with error: %v`, email, err.Error())+ }+ if user == nil {+ return nil, errors.Errorf("cannot found user %s", email)+ }+ return user, nil+}+// CreateIssue creates a issue.func (s *IssueService) CreateIssue(ctx context.Context, request *v1pb.CreateIssueRequest) (*v1pb.Issue, error) {creatorID := ctx.Value(common.PrincipalIDContextKey).(int)diff --git a/backend/store/issue.go b/backend/store/issue.goindex 7ffc7ff7de..01933cfabf 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -874,7 +874,7 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Issif 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 {+ if v := find.Query; v != nil && *v != "" {tsQuery := getTsQuery(*v)from += fmt.Sprintf(`, CAST($%d AS tsquery) AS query`, len(args)+1)args = append(args, tsQuery)diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 45aa49cfb5..ec21327f24 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -756,6 +756,8 @@},"view-commit": "View commit","search-issue-name": "Search issue name",+ "advanced-search": "Advanced search",+ "filter-issue-by-name": "Filter issue by name","table": {"open": "Open","closed": "Closed",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 19d1ce7109..580e63acce 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -755,6 +755,8 @@},"view-commit": "Ver commit","search-issue-name": "Buscar nombre de la incidencia",+ "advanced-search": "Búsqueda Avanzada",+ "filter-issue-by-name": "Filtrar problema por nombre","table": {"open": "Abierto","closed": "Cerrado",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 3b16b81158..f48db6e878 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -753,6 +753,8 @@},"view-commit": "查看提交","search-issue-name": "搜索工单名称",+ "advanced-search": "高级搜素",+ "filter-issue-by-name": "根据名称过滤","table": {"open": "开启中","closed": "已关闭",diff --git a/frontend/src/types/proto/v1/issue_service.ts b/frontend/src/types/proto/v1/issue_service.tsindex edc2361558..f2efdec8e1 100644--- a/frontend/src/types/proto/v1/issue_service.ts+++ b/frontend/src/types/proto/v1/issue_service.ts@@ -144,7 +144,22 @@ export interface SearchIssuesRequest {pageToken: string;/** Query is the query statement. */query: string;- /** Filter is used to filter issues returned in the list. */+ /**+ * Filter is used to filter issues returned in the list,+ * follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ * Supported field in filter:+ * - principal, example:+ * - principal = "users/{email}"+ * - creator, example:+ * - creator = "users/{email}"+ * - assignee, example:+ * - assignee = "users/{email}"+ * - subscriber, example:+ * - subscriber = "users/{email}"+ * - status, example:+ * - status = "OPEN"+ * - status = "DONE" | "CANCELED"+ */filter: string;}diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex b6bc4d1343..c81dd28241 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -5554,7 +5554,7 @@ When paginating, all other parameters provided to `ListIssues` must match the caWhen paginating, all other parameters provided to `SearchIssues` must match the call that provided the page token. || query | [string](#string) | | Query is the query statement. |-| filter | [string](#string) | | Filter is used to filter issues returned in the list. |+| filter | [string](#string) | | Filter is used to filter issues returned in the list, follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax. Supported field in filter: - principal, example: - principal = "users/{email}" - creator, example: - creator = "users/{email}" - assignee, example: - assignee = "users/{email}" - subscriber, example: - subscriber = "users/{email}" - status, example: - status = "OPEN" - status = "DONE" | "CANCELED" |diff --git a/proto/generated-go/v1/issue_service.pb.go b/proto/generated-go/v1/issue_service.pb.goindex a6dc53d695..8d74aafa0b 100644--- a/proto/generated-go/v1/issue_service.pb.go+++ b/proto/generated-go/v1/issue_service.pb.go@@ -677,7 +677,24 @@ type SearchIssuesRequest struct {PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`// Query is the query statement.Query string `protobuf:"bytes,4,opt,name=query,proto3" json:"query,omitempty"`- // Filter is used to filter issues returned in the list.+ // Filter is used to filter issues returned in the list,+ // follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ // Supported field in filter:+ // - principal, example:+ // - principal = "users/{email}"+ //+ // - creator, example:+ // - creator = "users/{email}"+ //+ // - assignee, example:+ // - assignee = "users/{email}"+ //+ // - subscriber, example:+ // - subscriber = "users/{email}"+ //+ // - status, example:+ // - status = "OPEN"+ // - status = "DONE" | "CANCELED"Filter string `protobuf:"bytes,5,opt,name=filter,proto3" json:"filter,omitempty"`}diff --git a/proto/v1/issue_service.proto b/proto/v1/issue_service.protoindex 796f3116dd..780349f7ad 100644--- a/proto/v1/issue_service.proto+++ b/proto/v1/issue_service.proto@@ -169,7 +169,20 @@ message SearchIssuesRequest {// Query is the query statement.string query = 4;- // Filter is used to filter issues returned in the list.+ // Filter is used to filter issues returned in the list,+ // follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ // Supported field in filter:+ // - principal, example:+ // - principal = "users/{email}"+ // - creator, example:+ // - creator = "users/{email}"+ // - assignee, example:+ // - assignee = "users/{email}"+ // - subscriber, example:+ // - subscriber = "users/{email}"+ // - status, example:+ // - status = "OPEN"+ // - status = "DONE" | "CANCELED"string filter = 5;}