Skip to content

Commit

Permalink
[feature]:(SQLManagement) build api and add schema column for list
Browse files Browse the repository at this point in the history
  • Loading branch information
LZS911 committed Dec 13, 2023
1 parent 5d25305 commit 0ac1167
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/api/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface IGetSqlManageListParams {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: GetSqlManageListSortFieldEnum;

sort_order?: GetSqlManageListSortOrderEnum;
Expand Down Expand Up @@ -90,6 +92,8 @@ export interface IExportSqlManageV1Params {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: exportSqlManageV1SortFieldEnum;

sort_order?: exportSqlManageV1SortOrderEnum;
Expand Down Expand Up @@ -127,6 +131,8 @@ export interface IGetSqlManageListV2Params {

fuzzy_search_endpoint?: string;

fuzzy_search_schema_name?: string;

sort_field?: GetSqlManageListV2SortFieldEnum;

sort_order?: GetSqlManageListV2SortOrderEnum;
Expand Down
2 changes: 1 addition & 1 deletion src/api/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
IGetSqlManageRuleTipsParams,
IGetSqlManageRuleTipsReturn,
IGetSqlManageListV2Params,
IGetSqlManageListV2Return,
IGetSqlManageListV2Return
} from './index.d';

class SqlManageService extends ServiceBase {
Expand Down
22 changes: 21 additions & 1 deletion src/api/audit_plan/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
ITriggerAuditPlanResV1,
IGetAuditPlansResV2,
IGetAuditPlanReportSQLsResV2,
IGetAuditPlanAnalysisDataResV2
IGetAuditPlanAnalysisDataResV2,
IFullSyncAuditPlanSQLsReqV2,
IPartialSyncAuditPlanSQLsReqV2
} from '../common.d';

export interface IGetAuditPlanMetasV1Params {
Expand Down Expand Up @@ -247,3 +249,21 @@ export interface IGetAuditPlantAnalysisDataV2Params {

export interface IGetAuditPlantAnalysisDataV2Return
extends IGetAuditPlanAnalysisDataResV2 {}

export interface IFullSyncAuditPlanSQLsV2Params
extends IFullSyncAuditPlanSQLsReqV2 {
project_name: string;

audit_plan_name: string;
}

export interface IFullSyncAuditPlanSQLsV2Return extends IBaseRes {}

export interface IPartialSyncAuditPlanSQLsV2Params
extends IPartialSyncAuditPlanSQLsReqV2 {
project_name: string;

audit_plan_name: string;
}

export interface IPartialSyncAuditPlanSQLsV2Return extends IBaseRes {}
42 changes: 41 additions & 1 deletion src/api/audit_plan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ import {
IGetAuditPlanReportsSQLsParams,
IGetAuditPlanReportsSQLsReturn,
IGetAuditPlantAnalysisDataV2Params,
IGetAuditPlantAnalysisDataV2Return
IGetAuditPlantAnalysisDataV2Return,
IFullSyncAuditPlanSQLsV2Params,
IFullSyncAuditPlanSQLsV2Return,
IPartialSyncAuditPlanSQLsV2Params,
IPartialSyncAuditPlanSQLsV2Return
} from './index.d';

class AuditPlanService extends ServiceBase {
Expand Down Expand Up @@ -446,6 +450,42 @@ class AuditPlanService extends ServiceBase {
options
);
}

public fullSyncAuditPlanSQLsV2(
params: IFullSyncAuditPlanSQLsV2Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

const audit_plan_name = paramsData.audit_plan_name;
delete paramsData.audit_plan_name;

return this.post<IFullSyncAuditPlanSQLsV2Return>(
`/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/full`,
paramsData,
options
);
}

public partialSyncAuditPlanSQLsV2(
params: IPartialSyncAuditPlanSQLsV2Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

const audit_plan_name = paramsData.audit_plan_name;
delete paramsData.audit_plan_name;

return this.post<IPartialSyncAuditPlanSQLsV2Return>(
`/v2/projects/${project_name}/audit_plans/${audit_plan_name}/sqls/partial`,
paramsData,
options
);
}
}

export default new AuditPlanService();
30 changes: 30 additions & 0 deletions src/api/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,28 @@ export interface IAuditPlanResV2 {
rule_template?: IRuleTemplateV2;
}

export interface IAuditPlanSQLReqV2 {
audit_plan_sql_counter?: string;

audit_plan_sql_fingerprint?: string;

audit_plan_sql_last_receive_text?: string;

audit_plan_sql_last_receive_timestamp?: string;

audit_plan_sql_schema?: string;

db_user?: string;

endpoints?: string[];

first_query_at?: string;

query_time_avg?: number;

query_time_max?: number;
}

export interface IAuditResDataV2 {
audit_level?: AuditResDataV2AuditLevelEnum;

Expand Down Expand Up @@ -3255,6 +3277,10 @@ export interface IDriverMeta {
logo_url?: string;
}

export interface IFullSyncAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];
}

export interface IGetAuditPlanAnalysisDataResV2 {
code?: number;

Expand Down Expand Up @@ -3391,6 +3417,10 @@ export interface IInstanceResV2 {
sql_query_config?: ISQLQueryConfigResV1;
}

export interface IPartialSyncAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];
}

export interface IPerformanceStatistics {
affect_rows?: IAffectRows;
}
Expand Down
48 changes: 34 additions & 14 deletions src/page/SQLManagement/SQLPanel/column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ export const SQLPanelColumns: (params: {
{
dataIndex: 'instance_name',
title: () => t('sqlManagement.table.instanceName'),
render: (name) => {

Check warning on line 118 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (!name) {
return '--';

Check warning on line 120 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 121 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 121 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
return name;

Check warning on line 122 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'schema_name',
title: () => 'Schema',

Check warning on line 127 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 127 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
render: (schema) => {

Check warning on line 128 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (!schema) {
return '--';

Check warning on line 130 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 131 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 131 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
return schema;

Check warning on line 132 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'audit_result',
Expand Down Expand Up @@ -168,23 +184,24 @@ export const SQLPanelColumns: (params: {
}
if (endpoints.length === 1) {
return <Tag>{endpoints[0]}</Tag>;

}
return (
<Popover content={
<div style={{ maxWidth: '600px' }}>
<Space wrap>{
endpoints.map((v) => (
<Tag key={v}>{v}</Tag>
))
}</Space>
</div>
}>
<Popover
content={
<div style={{ maxWidth: '600px' }}>
<Space wrap>
{endpoints.map((v) => (

Check warning on line 193 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
<Tag key={v}>{v}</Tag>

Check warning on line 194 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
))}
</Space>
</div>
}
>
<Tag>{endpoints[0]}</Tag>
{endpoints.length > 1 ? '...' : null}
</Popover >
)
}
</Popover>
);

Check warning on line 203 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
},
},
{
dataIndex: 'status',
Expand Down Expand Up @@ -215,7 +232,10 @@ export const SQLPanelColumns: (params: {
width: 200,
render: (remark: string, record) => {
return (
<EmptyBox if={actionPermission} defaultNode={<>{renderRemark(remark) ?? '--'}</>}>
<EmptyBox
if={actionPermission}
defaultNode={<>{renderRemark(remark) ?? '--'}</>}

Check warning on line 237 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 237 in src/page/SQLManagement/SQLPanel/column.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
>
<EditText
editable={{
autoSize: true,
Expand Down

0 comments on commit 0ac1167

Please sign in to comment.