Skip to content

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

chore: update issue filter specs (#12030)

boojack1b5368a50371
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 24e673f985..cbabc05034 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -227,6 +227,15 @@ func (s *IssueService) getIssueFind(ctx context.Context, permissionFilter *store
if spec.operator != comparatorTypeEqual {
return nil, status.Errorf(codes.InvalidArgument, `only support "=" operation for "type" filter`)
}
+ issueType, err := convertToAPIIssueType(v1pb.Issue_Type(v1pb.Issue_Type_value[spec.value]))
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, "failed to convert to issue type, err: %v", err)
+ }
+ issueFind.Types = &[]api.IssueType{issueType}
+ case "task_type":
+ if spec.operator != comparatorTypeEqual {
+ return nil, status.Errorf(codes.InvalidArgument, `only support "=" operation for "task_type" filter`)
+ }
switch spec.value {
case "DDL":
issueFind.TaskTypes = &[]api.TaskType{
diff --git a/backend/api/v1/issue_service_convert.go b/backend/api/v1/issue_service_convert.go
index 293860a97f..74f3e36c75 100644
--- a/backend/api/v1/issue_service_convert.go
+++ b/backend/api/v1/issue_service_convert.go
@@ -172,6 +172,19 @@ func convertToIssueType(t api.IssueType) v1pb.Issue_Type {
}
}
+func convertToAPIIssueType(t v1pb.Issue_Type) (api.IssueType, error) {
+ switch t {
+ case v1pb.Issue_DATABASE_CHANGE:
+ return api.IssueDatabaseGeneral, nil
+ case v1pb.Issue_GRANT_REQUEST:
+ return api.IssueGrantRequest, nil
+ case v1pb.Issue_DATABASE_DATA_EXPORT:
+ return api.IssueDatabaseDataExport, nil
+ default:
+ return api.IssueType(""), errors.Errorf("invalid issue type %v", t)
+ }
+}
+
func convertToAPIIssueStatus(status v1pb.IssueStatus) (api.IssueStatus, error) {
switch status {
case v1pb.IssueStatus_OPEN:
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 7536f473d4..03b584668d 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -98,6 +98,7 @@ type FindIssueMessage struct {
SubscriberID *int
CreatedTsBefore *int64
CreatedTsAfter *int64
+ Types *[]api.IssueType
StatusList []api.IssueStatus
TaskTypes *[]api.TaskType
@@ -435,6 +436,10 @@ 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.Types; v != nil {
+ where = append(where, fmt.Sprintf("issue.type = ANY($%d)", len(args)+1))
+ args = append(args, *v)
+ }
if v := find.Query; v != nil && *v != "" {
if tsQuery := getTsQuery(*v); tsQuery != "" {
from += fmt.Sprintf(` LEFT JOIN CAST($%d AS tsquery) AS query ON TRUE`, len(args)+1)
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
index 85efe56ff7..036f3a5243 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
@@ -45,18 +45,7 @@ import { UIIssueFilterScopeIdList, SearchScopeIdList } from "@/utils";
import Status from "./Status.vue";
import { useIssueSearchScopeOptions } from "./useIssueSearchScopeOptions";
-export type SearchComponent =
- | "searchbox"
- | "status"
- | "type"
- | "time-range"
- | "project"
- | "instance"
- | "database"
- | "assignee"
- | "creator"
- | "approver"
- | "approval";
+export type SearchComponent = "searchbox" | "status" | "time-range";
const props = withDefaults(
defineProps<{
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
index cb1b3612cd..ea4f5a7d3f 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
+++ b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
@@ -163,7 +163,7 @@ export const useIssueSearchScopeOptions = (
options: principalSearchValueOptions.value,
},
{
- id: "type",
+ id: "taskType",
title: t("issue.advanced-search.scope.type.title"),
description: t("issue.advanced-search.scope.type.description"),
options: [
diff --git a/frontend/src/store/modules/v1/issue.ts b/frontend/src/store/modules/v1/issue.ts
index 0782bd5c66..f6c2646b3a 100644
--- a/frontend/src/store/modules/v1/issue.ts
+++ b/frontend/src/store/modules/v1/issue.ts
@@ -61,6 +61,9 @@ export const buildIssueFilter = (find: IssueFilter): string => {
if (find.type) {
filter.push(`type = "${find.type}"`);
}
+ if (find.taskType) {
+ filter.push(`task_type = "${find.taskType}"`);
+ }
if (find.instance) {
filter.push(`instance = "${find.instance}"`);
}
@@ -70,6 +73,9 @@ export const buildIssueFilter = (find: IssueFilter): string => {
if (find.labels && find.labels.length > 0) {
filter.push(`labels = "${find.labels.join(" & ")}"`);
}
+ if (find.hasPipeline !== undefined) {
+ filter.push(`has_pipeline = "${find.hasPipeline}"`);
+ }
return filter.join(" && ");
};
diff --git a/frontend/src/types/v1/issue/issue.ts b/frontend/src/types/v1/issue/issue.ts
index 1aac5a3065..b9e5083b53 100644
--- a/frontend/src/types/v1/issue/issue.ts
+++ b/frontend/src/types/v1/issue/issue.ts
@@ -86,7 +86,11 @@ export interface IssueFilter {
statusList?: IssueStatus[];
createdTsAfter?: number;
createdTsBefore?: number;
- type?: string;
+ // type is the issue type, for example: GRANT_REQUEST, DATABASE_DATA_EXPORT
+ type?: Issue_Type;
+ // taskType is the task type, for example: DDL, DML
+ taskType?: string;
// filter by labels, for example: labels = "feature & bug"
labels?: string[];
+ hasPipeline?: boolean;
}
diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.ts
index 3c2ec3ec4d..3a516fe327 100644
--- a/frontend/src/utils/v1/advanced-search/common.ts
+++ b/frontend/src/utils/v1/advanced-search/common.ts
@@ -21,12 +21,12 @@ export const SearchScopeIdList = [
"database",
"creator",
"created",
- "type",
"status",
// issue related search scopes.
"assignee",
"subscriber",
"label",
+ "taskType",
// auditLog related search scopes.
"method",
"level",
diff --git a/frontend/src/utils/v1/advanced-search/issue/utils.ts b/frontend/src/utils/v1/advanced-search/issue/utils.ts
index bc091a6764..32b4388d97 100644
--- a/frontend/src/utils/v1/advanced-search/issue/utils.ts
+++ b/frontend/src/utils/v1/advanced-search/issue/utils.ts
@@ -3,12 +3,18 @@ import type { IssueFilter } from "@/types";
import { UNKNOWN_ID } from "@/types";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import type { SearchParams, SemanticIssueStatus } from "../common";
-import { getTsRangeFromSearchParams, getValueFromSearchParams } from "../common";
+import {
+ getTsRangeFromSearchParams,
+ getValueFromSearchParams,
+} from "../common";
-export const buildIssueFilterBySearchParams = (params: SearchParams) => {
+export const buildIssueFilterBySearchParams = (
+ params: SearchParams,
+ defaultFilter?: Partial<IssueFilter>
+) => {
const { query, scopes } = params;
const projectScope = scopes.find((s) => s.id === "project");
- const typeScope = scopes.find((s) => s.id === "type");
+ const taskTypeScope = scopes.find((s) => s.id === "taskType");
const databaseScope = scopes.find((s) => s.id === "database");
let database = "";
@@ -25,13 +31,14 @@ export const buildIssueFilterBySearchParams = (params: SearchParams) => {
const label = getValueFromSearchParams(params, "label");
const filter: IssueFilter = {
+ ...defaultFilter,
query,
instance: getValueFromSearchParams(params, "instance", "instances/"),
database,
project: `projects/${projectScope?.value ?? "-"}`,
createdTsAfter: createdTsRange?.[0],
createdTsBefore: createdTsRange?.[1],
- type: typeScope?.value,
+ taskType: taskTypeScope?.value,
creator: getValueFromSearchParams(params, "creator", "users/"),
assignee: getValueFromSearchParams(params, "assignee", "users/"),
subscriber: getValueFromSearchParams(params, "subscriber", "users/"),
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
index fde1bd3699..66673795da 100644
--- a/frontend/src/views/ExportCenter/index.vue
+++ b/frontend/src/views/ExportCenter/index.vue
@@ -34,7 +34,6 @@
v-model:loading-more="state.loadingMore"
:session-key="'export-center'"
:issue-filter="mergedIssueFilter"
- :ui-issue-filter="mergedUIIssueFilter"
:page-size="50"
:compose-issue-config="{ withRollout: true }"
>
@@ -71,9 +70,9 @@ import PagedIssueTableV1 from "@/components/IssueV1/components/PagedIssueTableV1
import { Drawer } from "@/components/v2";
import { useCurrentUserV1, useProjectV1Store } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
+import { Issue_Type } from "@/types/proto/v1/issue_service";
import {
buildIssueFilterBySearchParams,
- buildUIIssueFilterBySearchParams,
extractProjectResourceName,
hasPermissionToCreateDataExportIssueInProject,
type SearchParams,
@@ -81,14 +80,12 @@ import {
type SearchScopeId,
} from "@/utils";
import DataExportIssueDataTable from "./DataExportIssueDataTable";
-import type { ExportRecord } from "./types";
const props = defineProps<{
projectId?: string;
}>();
interface LocalState {
- exportRecords: ExportRecord[];
showRequestExportPanel: boolean;
params: SearchParams;
loading: boolean;
@@ -124,7 +121,6 @@ const defaultSearchParams = () => {
const currentUser = useCurrentUserV1();
const projectV1Store = useProjectV1Store();
const state = reactive<LocalState>({
- exportRecords: [],
showRequestExportPanel: false,
params: defaultSearchParams(),
loading: false,
@@ -134,10 +130,6 @@ const state = reactive<LocalState>({
const dataExportIssueSearchParams = computed(() => {
// Default scopes with type and creator.
const defaultScopes = [
- {
- id: "type",
- value: "DATA_EXPORT",
- },
{
id: "creator",
value: currentUser.value.email,
@@ -170,11 +162,9 @@ const overideSearchScopeIdList = computed(() => {
});
const mergedIssueFilter = computed(() => {
- return buildIssueFilterBySearchParams(dataExportIssueSearchParams.value);
-});
-
-const mergedUIIssueFilter = computed(() => {
- return buildUIIssueFilterBySearchParams(dataExportIssueSearchParams.value);
+ return buildIssueFilterBySearchParams(dataExportIssueSearchParams.value, {
+ type: Issue_Type.DATABASE_DATA_EXPORT,
+ });
});
const allowExportData = computed(() => {
diff --git a/frontend/src/views/ExportCenter/types.ts b/frontend/src/views/ExportCenter/types.ts
deleted file mode 100644
index bf2c5a6809..0000000000
--- a/frontend/src/views/ExportCenter/types.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { ComposedDatabase, DatabaseResource } from "@/types";
-
-export interface ExportRecord {
- databaseResource: DatabaseResource;
- database: ComposedDatabase;
- expiration: string;
- statement: string;
- maxRowCount: number;
- exportFormat: "CSV" | "JSON" | "SQL" | "XLSX";
- // issueId is the uid of an issue.
- issueId: string;
-}