Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 2868 #567

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/shared/lib/api/sqle/service/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
IGetGlobalSqlManageListResp,
IGetGlobalSqlManageStatisticsResp,
IGetSqlManageListResp,
IGetAbnormalAuditPlanInstancesResp,
IBatchUpdateSqlManageReq,
IBaseRes,
IGetSqlManageRuleTipsResp,
Expand Down Expand Up @@ -97,6 +98,13 @@ export interface IGetSqlManageListParams {

export interface IGetSqlManageListReturn extends IGetSqlManageListResp {}

export interface IGetAbnormalInstanceAuditPlansV1Params {
project_name: string;
}

export interface IGetAbnormalInstanceAuditPlansV1Return
extends IGetAbnormalAuditPlanInstancesResp {}

export interface IBatchUpdateSqlManageParams extends IBatchUpdateSqlManageReq {
project_name: string;
}
Expand Down
17 changes: 17 additions & 0 deletions packages/shared/lib/api/sqle/service/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
IGetGlobalSqlManageStatisticsReturn,
IGetSqlManageListParams,
IGetSqlManageListReturn,
IGetAbnormalInstanceAuditPlansV1Params,
IGetAbnormalInstanceAuditPlansV1Return,
IBatchUpdateSqlManageParams,
IBatchUpdateSqlManageReturn,
IExportSqlManageV1Params,
Expand Down Expand Up @@ -68,6 +70,21 @@ class SqlManageService extends ServiceBase {
);
}

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

return this.get<IGetAbnormalInstanceAuditPlansV1Return>(
`/v1/projects/${project_name}/sql_manages/abnormal_audit_plan_instance`,
paramsData,
options
);
}

public BatchUpdateSqlManage(
params: IBatchUpdateSqlManageParams,
options?: AxiosRequestConfig
Expand Down
27 changes: 27 additions & 0 deletions packages/shared/lib/api/sqle/service/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
AuditPlanParamResV1TypeEnum,
AuditPlanReportResV1AuditLevelEnum,
AuditPlanSQLHeadV1TypeEnum,
AuditPlanTypeResBaseActiveStatusEnum,
AuditPlanTypeResBaseLastCollectionStatusEnum,
AuditPlanTypesV1InstanceTypeEnum,
AuditResDataV1AuditLevelEnum,
AuditTaskResV1AuditLevelEnum,
Expand Down Expand Up @@ -32,6 +34,7 @@ import {
HighPriorityConditionReqOperatorEnum,
HighPriorityConditionResV1TypeEnum,
InstanceAuditPlanInfoActiveStatusEnum,
InstanceAuditPlanInfoLastCollectionStatusEnum,
InstanceAuditPlanResV1ActiveStatusEnum,
InstanceTipResV1SupportedBackupStrategyEnum,
ModuleRedDotModuleNameEnum,
Expand Down Expand Up @@ -122,6 +125,12 @@ export interface IRuleCategoryStatistic {
tag?: string;
}

export interface IAbnormalAuditPlanInstance {
instance_audit_plan_id?: number;

instance_name?: string;
}

export interface IAffectRows {
count?: number;

Expand Down Expand Up @@ -301,10 +310,14 @@ export interface IAuditPlanSQLResV1 {
}

export interface IAuditPlanTypeResBase {
active_status?: AuditPlanTypeResBaseActiveStatusEnum;

audit_plan_id?: number;

desc?: string;

last_collection_status?: AuditPlanTypeResBaseLastCollectionStatusEnum;

token?: string;

type?: string;
Expand Down Expand Up @@ -1072,6 +1085,14 @@ export interface IGenModifylSQLReqV1 {
database_schema_objects?: IDatabaseSchemaObject[];
}

export interface IGetAbnormalAuditPlanInstancesResp {
code?: number;

data?: IAbnormalAuditPlanInstance[];

message?: string;
}

export interface IGetAuditPlanAnalysisDataResV1 {
code?: number;

Expand Down Expand Up @@ -2119,6 +2140,8 @@ export interface IInstanceAuditPlanInfo {

id?: number;

last_collection_status?: InstanceAuditPlanInfoLastCollectionStatusEnum;

last_collection_time?: string;

total_sql_nums?: number;
Expand Down Expand Up @@ -3994,6 +4017,8 @@ export interface IExecResultCount {

export interface IFullSyncAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];

error_message?: string;
}

export interface IGetAuditFileExecStatisticRes {
Expand Down Expand Up @@ -4182,6 +4207,8 @@ export interface IUpdateWorkflowScheduleReqV2 {

export interface IUploadInstanceAuditPlanSQLsReqV2 {
audit_plan_sql_list?: IAuditPlanSQLReqV2[];

error_message?: string;
}

export interface IWorkflowRecordResV2 {
Expand Down
18 changes: 18 additions & 0 deletions packages/shared/lib/api/sqle/service/common.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export enum AuditPlanSQLHeadV1TypeEnum {
'sql' = 'sql'
}

export enum AuditPlanTypeResBaseActiveStatusEnum {
'normal' = 'normal',

'disabled' = 'disabled'
}

export enum AuditPlanTypeResBaseLastCollectionStatusEnum {
'normal' = 'normal',

'abnormal' = 'abnormal'
}

export enum AuditPlanTypesV1InstanceTypeEnum {
'MySQL' = 'MySQL',

Expand Down Expand Up @@ -332,6 +344,12 @@ export enum InstanceAuditPlanInfoActiveStatusEnum {
'disabled' = 'disabled'
}

export enum InstanceAuditPlanInfoLastCollectionStatusEnum {
'normal' = 'normal',

'abnormal' = 'abnormal'
}

export enum InstanceAuditPlanResV1ActiveStatusEnum {
'normal' = 'normal',

Expand Down
12 changes: 10 additions & 2 deletions packages/sqle/src/locale/zh-CN/managementConf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default {
scanStatus: '采集状态',
notificationMethod: '推送方式',
createdAt: '创建时间',
creator: '创建人'
creator: '创建人',
abnormalTips: 'SQL采集存在异常'
},
action: {
disabled: {
Expand Down Expand Up @@ -117,7 +118,14 @@ export default {
connectionInfo: '连接信息',
collectedSqlCount: '采集到的SQL数',
problematicSqlCount: '审核有问题的SQL数',
lastCollectionTime: '最近一次采集时间'
lastCollectionTime: '最近一次采集时间',
taskStatus: {
disabled: '停用',
normal: '运行中',
abnormal: '运行异常'
},
abnormalTips:
'请根据"execute extract sql failed"关键字到sqled.log日志中检索相关信息'
},
actions: {
enabled: '启用',
Expand Down
2 changes: 2 additions & 0 deletions packages/sqle/src/locale/zh-CN/sqlManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default {
problemSQlNum: '问题SQL数',
optimizedSQLNum: '已优化SQL数'
},
abnormalAuditPlanTips:
'上的SQL采集存在问题,为保障SQL管控功能正常运行,请及时进行诊断排查',
ceTips:
'SQL管控为用户提供SQL全生命周期监控,面板将整合所有的业务SQL,用户可以在该面板中查看项目中采集并审核的所有SQL,暴露其中的问题SQL,同时支持用户解决问题SQL。',
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ exports[`page/SqlManagement render sql management page 1`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ exports[`page/SqlManagement/SQLEEIndex filter data with rule name 1`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -2220,7 +2220,7 @@ exports[`page/SqlManagement/SQLEEIndex render sql statics data 1`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -3021,7 +3021,7 @@ exports[`page/SqlManagement/SQLEEIndex render table data 1`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -5868,7 +5868,7 @@ exports[`page/SqlManagement/SQLEEIndex render table data when preferred language
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -8715,7 +8715,7 @@ exports[`page/SqlManagement/SQLEEIndex render table data when preferred language
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -11578,7 +11578,7 @@ exports[`page/SqlManagement/SQLEEIndex render table with permissions 1`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -12735,7 +12735,7 @@ exports[`page/SqlManagement/SQLEEIndex render table with permissions 2`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down Expand Up @@ -13862,7 +13862,7 @@ exports[`page/SqlManagement/SQLEEIndex render table with permissions 3`] = `
</div>
</div>
<div
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1xsk37k css-dev-only-do-not-override-bj9uhl"
class="ant-table-wrapper actiontech-table-namespace table-row-cursor css-1wtv5xm css-dev-only-do-not-override-bj9uhl"
>
<div
class="ant-spin-nested-loading css-dev-only-do-not-override-bj9uhl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { act, cleanup, fireEvent, screen } from '@testing-library/react';
import SQLEEIndex from '.';
import { superRender } from '../../../../testUtils/customRender';
import sqlManage from '../../../../testUtils/mockApi/sqlManage';
import { mockAbnormalInstanceAuditPlansData } from '../../../../testUtils/mockApi/sqlManage/data';
import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject';
import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser';
import { mockUseProjectBusinessTips } from '@actiontech/shared/lib/testUtil/mockHook/mockUseProjectBusinessTips';
Expand Down Expand Up @@ -825,4 +826,15 @@ describe('page/SqlManagement/SQLEEIndex', () => {
payload: [sqlManageListData.data[0]]
});
});

it('render abnormal status audit plan tips when request return data', async () => {
const request = sqlManage.getAbnormalInstanceAuditPlans();
request.mockImplementation(() =>
createSpySuccessResponse({ data: mockAbnormalInstanceAuditPlansData })
);
superRender(<SQLEEIndex />);
expect(request).toHaveBeenCalled();
await act(async () => jest.advanceTimersByTime(3000));
expect(getBySelector('.ant-alert-warning')).toBeInTheDocument();
});
});
Loading
Loading