Skip to content

Commit 45741d5

Browse files
committed
[chore](SqlOptimization): Optimize result code
1 parent 8776caf commit 45741d5

File tree

7 files changed

+41
-61
lines changed

7 files changed

+41
-61
lines changed

packages/sqle/src/page/SqlOptimization/Result/Modal/TableStructureModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ const TableStructureModal: React.FC = () => {
6464
<BasicInput.TextArea
6565
value={currentTableData?.tableStructure}
6666
readOnly
67-
autoSize={{
68-
maxRows: 10,
69-
minRows: 6
70-
}}
67+
rows={8}
7168
bordered={false}
7269
/>
7370
</EmptyBox>

packages/sqle/src/page/SqlOptimization/Result/Modal/style.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ export const TableStructureModalWrapper = styled('div')`
2727
border: 1px solid
2828
${({ theme }) => theme.sharedTheme.uiToken.colorBorderSecondary};
2929
border-radius: 8px;
30-
overflow: hidden;
31-
max-height: 300px;
32-
overflow-y: auto;
3330
}
3431
}
3532
`;

packages/sqle/src/page/SqlOptimization/Result/components/AnalysisChart.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import ChartWrapper from '../../../../components/ChartCom/ChartWrapper';
33
import { useTranslation } from 'react-i18next';
44
import { useMemo } from 'react';
55
import { AnalysisChartWrapper } from './style';
6-
import { ITotalAnalysis } from '@actiontech/shared/lib/api/sqle/service/common';
6+
import {
7+
ITotalAnalysis,
8+
IAnalysisDetail
9+
} from '@actiontech/shared/lib/api/sqle/service/common';
710
import { OptimizationSQLDetailStatusEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum';
811
interface AnalysisChartProps {
912
data?: ITotalAnalysis;
@@ -27,16 +30,16 @@ const AnalysisChart: React.FC<AnalysisChartProps> = ({
2730
type: string;
2831
}> = [];
2932

30-
data?.detail?.forEach((item: any) => {
33+
data?.detail?.forEach((item: IAnalysisDetail) => {
3134
transformedData.push(
3235
{
33-
name: item.category,
34-
score: item.original_score,
36+
name: item.category ?? '',
37+
score: item.original_score ?? 0,
3538
type: t('sqlOptimization.result.original')
3639
},
3740
{
38-
name: item.category,
39-
score: item.optimized_score,
41+
name: item.category ?? '',
42+
score: item.optimized_score ?? 0,
4043
type: t('sqlOptimization.result.finalOptimized')
4144
}
4245
);
@@ -84,12 +87,11 @@ const AnalysisChart: React.FC<AnalysisChartProps> = ({
8487
fillOpacity: 0.15
8588
}
8689
},
87-
8890
tooltip: {
89-
formatter: (datum: any) => {
91+
formatter: (datum) => {
9092
return {
91-
name: datum.type,
92-
value: `${datum.score}分`
93+
name: datum?.type ?? '',
94+
value: `${datum?.score ?? 0}分`
9395
};
9496
}
9597
},

packages/sqle/src/page/SqlOptimization/Result/components/LeftContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const LeftContent: React.FC<LeftContentProps> = ({
104104
icon={<FullScreenOutlined />}
105105
size="small"
106106
onClick={onExpandQueryPlan}
107+
className="view-query-plan-diff-button"
107108
>
108109
{t('sqlOptimization.result.expand')}
109110
</BasicButton>

packages/sqle/src/page/SqlOptimization/Result/components/QueryPlanFlow/QueryPlanNode.tsx

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,7 @@ import type { Node, NodeProps } from '@xyflow/react';
44
import { Space, Typography } from 'antd';
55
import { DownOutlined, RightOutlined } from '@ant-design/icons';
66
import { QueryPlanNodeWrapper } from '../style';
7-
import { ExecutionPlanType } from '../../index.type';
8-
9-
interface QueryPlanItem {
10-
summary: string[];
11-
children: QueryPlanItem[];
12-
operator: string;
13-
[x: string]: any;
14-
}
15-
16-
interface QueryPlanNodeData extends Record<string, unknown> {
17-
detail: QueryPlanItem;
18-
level: number;
19-
hasChildren?: boolean;
20-
isRootNode?: boolean;
21-
nodeIndex?: number;
22-
planType?: ExecutionPlanType;
23-
}
7+
import { QueryPlanNodeData } from './index.type';
248

259
const QueryPlanNode: React.FC<NodeProps<Node<QueryPlanNodeData>>> = ({
2610
data,
@@ -37,25 +21,7 @@ const QueryPlanNode: React.FC<NodeProps<Node<QueryPlanNodeData>>> = ({
3721
const [isExpanded, setIsExpanded] = useState(true);
3822

3923
const content = useMemo(() => {
40-
let conditionString = '';
41-
if (detail?.conditions) {
42-
detail?.conditions?.forEach((item: any) => {
43-
if (typeof item === 'string') {
44-
conditionString += JSON.stringify(item);
45-
}
46-
});
47-
}
48-
49-
const summaryString = detail?.summary?.join('\n');
50-
51-
const contentStr =
52-
detail?.columns?.join('') ||
53-
detail?.table ||
54-
detail?.join_condition ||
55-
conditionString ||
56-
summaryString ||
57-
'';
58-
return contentStr;
24+
return detail?.summary?.join('\n');
5925
}, [detail]);
6026

6127
const handleToggleExpand = (event: React.MouseEvent) => {

packages/sqle/src/page/SqlOptimization/Result/components/QueryPlanFlow/index.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ import '@xyflow/react/dist/style.css';
44
import { QueryPlanFlowWrapper } from '../style';
55
import QueryPlanNode from './QueryPlanNode';
66
import { IQueryPlanNode } from '@actiontech/shared/lib/api/sqle/service/common';
7-
import { ExecutionPlanType } from '../../index.type';
8-
9-
interface QueryPlanFlowProps {
10-
queryPlanDesc: IQueryPlanNode[];
11-
height?: number;
12-
fitViewTrigger?: number; // 用于触发重新适应视图
13-
planType?: ExecutionPlanType; // 执行计划类型
14-
}
7+
import { QueryPlanFlowProps } from './index.type';
158

169
const QueryPlanFlow: React.FC<QueryPlanFlowProps> = ({
1710
queryPlanDesc,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ExecutionPlanType } from '../../index.type';
2+
import { IQueryPlanNode } from '@actiontech/shared/lib/api/sqle/service/common';
3+
4+
export interface QueryPlanItem {
5+
summary: string[];
6+
children: QueryPlanItem[];
7+
operator: string;
8+
}
9+
10+
export type QueryPlanNodeData = {
11+
detail: QueryPlanItem;
12+
level: number;
13+
hasChildren?: boolean;
14+
isRootNode?: boolean;
15+
nodeIndex?: number;
16+
planType?: ExecutionPlanType;
17+
};
18+
19+
export interface QueryPlanFlowProps {
20+
queryPlanDesc: IQueryPlanNode[];
21+
height?: number;
22+
fitViewTrigger?: number; // 用于触发重新适应视图
23+
planType?: ExecutionPlanType; // 执行计划类型
24+
}

0 commit comments

Comments
 (0)