Skip to content

Commit df0abde

Browse files
authored
Merge branch 'main' into astandrik.snippets-for-table-1299
2 parents d81165a + 82531a5 commit df0abde

File tree

10 files changed

+181
-115
lines changed

10 files changed

+181
-115
lines changed

src/containers/Tenant/Diagnostics/Describe/Describe.tsx

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {ClipboardButton} from '@gravity-ui/uikit';
2-
import {skipToken} from '@reduxjs/toolkit/query';
32
import JSONTree from 'react-json-inspector';
43
import {shallowEqual} from 'react-redux';
54

65
import {ResponseError} from '../../../../components/Errors/ResponseError';
76
import {Loader} from '../../../../components/Loader';
8-
import {overviewApi} from '../../../../store/reducers/overview/overview';
9-
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
7+
import {
8+
selectSchemaMergedChildrenPaths,
9+
useGetMultiOverviewQuery,
10+
} from '../../../../store/reducers/overview/overview';
1011
import type {EPathType} from '../../../../types/api/schema';
11-
import type {IDescribeData} from '../../../../types/store/describe';
1212
import {cn} from '../../../../utils/cn';
1313
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1414
import {isEntityWithMergedImplementation} from '../../utils/schema';
@@ -26,8 +26,6 @@ interface IDescribeProps {
2626
type?: EPathType;
2727
}
2828

29-
const emptyObject: IDescribeData = {};
30-
3129
const Describe = ({path, database, type}: IDescribeProps) => {
3230
const [autoRefreshInterval] = useAutoRefreshInterval();
3331

@@ -44,37 +42,20 @@ const Describe = ({path, database, type}: IDescribeProps) => {
4442
} else if (mergedChildrenPaths) {
4543
paths = [path, ...mergedChildrenPaths];
4644
}
47-
const {currentDescribe, currentData, isFetching, error} = overviewApi.useGetOverviewQuery(
48-
paths.length ? {paths, database} : skipToken,
49-
{
50-
pollingInterval: autoRefreshInterval,
51-
selectFromResult: (props) => {
52-
const {currentData} = props;
53-
if (!currentData) {
54-
return {currentDescribe: emptyObject, ...props};
55-
}
56-
57-
const mergedData = [currentData.data, ...currentData.additionalData];
5845

59-
const data = mergedData.reduce<IDescribeData>((acc, item) => {
60-
if (item?.Path) {
61-
acc[item.Path] = item;
62-
}
63-
return acc;
64-
}, {});
65-
return {currentDescribe: data, ...props};
66-
},
67-
},
68-
);
69-
const loading = isFetching && currentData === undefined;
46+
const {mergedDescribe, loading, error} = useGetMultiOverviewQuery({
47+
paths,
48+
autoRefreshInterval,
49+
database,
50+
});
7051

7152
let preparedDescribeData: Object | undefined;
72-
if (currentDescribe) {
73-
const paths = Object.keys(currentDescribe);
53+
if (mergedDescribe) {
54+
const paths = Object.keys(mergedDescribe);
7455
if (paths.length === 1) {
75-
preparedDescribeData = currentDescribe[paths[0]];
56+
preparedDescribeData = mergedDescribe[paths[0]];
7657
} else {
77-
preparedDescribeData = currentDescribe;
58+
preparedDescribeData = mergedDescribe;
7859
}
7960
}
8061

src/containers/Tenant/Diagnostics/HotKeys/HotKeys.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ export function HotKeys({path, database}: HotKeysProps) {
6262
const {currentData: data, isFetching, error} = hotKeysApi.useGetHotKeysQuery({path, database});
6363
const loading = isFetching && data === undefined;
6464
const [autoRefreshInterval] = useAutoRefreshInterval();
65-
const {currentData, isLoading: schemaLoading} = overviewApi.useGetOverviewQuery(
65+
const {currentData: schemaData, isLoading: schemaLoading} = overviewApi.useGetOverviewQuery(
6666
{
67-
paths: [path],
67+
path,
6868
database,
6969
},
7070
{
7171
pollingInterval: autoRefreshInterval,
7272
},
7373
);
74-
const {data: schemaData} = currentData ?? {};
7574
const keyColumnsIds = schemaData?.PathDescription?.Table?.KeyColumnNames;
7675

7776
const tableColumns = React.useMemo(() => {

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react';
22

3-
import {skipToken} from '@reduxjs/toolkit/query';
43
import {shallowEqual} from 'react-redux';
54

65
import {ResponseError} from '../../../../components/Errors/ResponseError';
76
import {TableIndexInfo} from '../../../../components/InfoViewer/schemaInfo';
87
import {Loader} from '../../../../components/Loader';
9-
import {overviewApi} from '../../../../store/reducers/overview/overview';
10-
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
8+
import {
9+
selectSchemaMergedChildrenPaths,
10+
useGetMultiOverviewQuery,
11+
} from '../../../../store/reducers/overview/overview';
1112
import {EPathType} from '../../../../types/api/schema';
1213
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1314
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
@@ -45,16 +46,17 @@ function Overview({type, path, database}: OverviewProps) {
4546
}
4647

4748
const {
48-
currentData,
49-
isFetching,
50-
error: overviewError,
51-
} = overviewApi.useGetOverviewQuery(paths.length ? {paths, database} : skipToken, {
52-
pollingInterval: autoRefreshInterval,
49+
mergedDescribe,
50+
loading: entityLoading,
51+
error,
52+
} = useGetMultiOverviewQuery({
53+
paths,
54+
database,
55+
autoRefreshInterval,
5356
});
54-
const overviewLoading = isFetching && currentData === undefined;
55-
const {data: rawData, additionalData} = currentData || {};
5657

57-
const entityLoading = overviewLoading;
58+
const rawData = mergedDescribe[path];
59+
5860
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;
5961

6062
const renderContent = () => {
@@ -70,14 +72,20 @@ function Overview({type, path, database}: OverviewProps) {
7072
[EPathType.EPathTypeExtSubDomain]: undefined,
7173
[EPathType.EPathTypeColumnStore]: undefined,
7274
[EPathType.EPathTypeColumnTable]: undefined,
73-
[EPathType.EPathTypeCdcStream]: () => (
74-
<ChangefeedInfo
75-
path={path}
76-
database={database}
77-
data={data}
78-
topic={additionalData?.[0] ?? undefined}
79-
/>
80-
),
75+
[EPathType.EPathTypeCdcStream]: () => {
76+
const topicPath = mergedChildrenPaths?.[0];
77+
if (topicPath) {
78+
return (
79+
<ChangefeedInfo
80+
path={path}
81+
database={database}
82+
data={data}
83+
topic={mergedDescribe?.[topicPath] ?? undefined}
84+
/>
85+
);
86+
}
87+
return undefined;
88+
},
8189
[EPathType.EPathTypePersQueueGroup]: () => (
8290
<TopicInfo data={data} path={path} database={database} />
8391
),
@@ -96,8 +104,8 @@ function Overview({type, path, database}: OverviewProps) {
96104

97105
return (
98106
<React.Fragment>
99-
{overviewError ? <ResponseError error={overviewError} /> : null}
100-
{overviewError && !rawData ? null : renderContent()}
107+
{error ? <ResponseError error={error} /> : null}
108+
{error && !rawData ? null : renderContent()}
101109
</React.Fragment>
102110
);
103111
}

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ export function TenantOverview({
4545

4646
const tenantType = mapDatabaseTypeToDBName(Type);
4747
// FIXME: remove after correct data is added to tenantInfo
48-
const {currentData} = overviewApi.useGetOverviewQuery(
48+
const {currentData: tenantSchemaData} = overviewApi.useGetOverviewQuery(
4949
{
50-
paths: [tenantName],
50+
path: tenantName,
5151
database: tenantName,
5252
},
5353
{
5454
pollingInterval: autoRefreshInterval,
5555
},
5656
);
57-
const {data: tenantSchemaData} = currentData ?? {};
5857
const {Tables, Topics} =
5958
tenantSchemaData?.PathDescription?.DomainDescription?.DiskSpaceUsage || {};
6059

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ export function ObjectSummary({
9393
ignoreQueryPrefix: true,
9494
});
9595

96-
const {currentData} = overviewApi.useGetOverviewQuery(
96+
const {currentData: currentObjectData} = overviewApi.useGetOverviewQuery(
9797
{
98-
paths: [path],
98+
path,
9999
database: tenantName,
100100
},
101101
{
102102
pollingInterval: autoRefreshInterval,
103103
},
104104
);
105-
const {data: currentObjectData} = currentData ?? {};
106105
const currentSchemaData = currentObjectData?.PathDescription?.Self;
107106

108107
React.useEffect(() => {

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ interface SchemaViewerProps {
3838

3939
export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaViewerProps) => {
4040
const [autoRefreshInterval] = useAutoRefreshInterval();
41-
const {currentData, isLoading: loading} = overviewApi.useGetOverviewQuery(
41+
const {currentData: schemaData, isLoading: loading} = overviewApi.useGetOverviewQuery(
4242
{
43-
paths: [path],
43+
path,
4444
database: tenantName,
4545
},
4646
{
4747
pollingInterval: autoRefreshInterval,
4848
},
4949
);
5050

51-
const {data: schemaData} = currentData ?? {};
52-
5351
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
5452

5553
const {data: viewColumnsData, isLoading: isViewSchemaLoading} =

src/containers/Tenant/Tenant.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ export function Tenant(props: TenantProps) {
7575

7676
const path = schema ?? tenantName;
7777

78-
const {currentData, error, isLoading} = overviewApi.useGetOverviewQuery(
79-
{paths: [path], database: tenantName},
78+
const {
79+
currentData: currentItem,
80+
error,
81+
isLoading,
82+
} = overviewApi.useGetOverviewQuery(
83+
{path, database: tenantName},
8084
{
8185
pollingInterval: autoRefreshInterval,
8286
},
8387
);
84-
const {data: currentItem} = currentData ?? {};
8588
const {PathType: currentPathType, PathSubType: currentPathSubType} =
8689
currentItem?.PathDescription?.Self || {};
8790

src/store/reducers/executeTopQueries/executeTopQueries.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {getFiltersConditions} from './utils';
1010

1111
const initialState: TopQueriesFilters = {};
1212

13+
const QUERY_TECHNICAL_MARK = '/*UI-QUERY-EXCLUDE*/';
14+
1315
const slice = createSlice({
1416
name: 'executeTopQueries',
1517
initialState,
@@ -26,7 +28,7 @@ export default slice.reducer;
2628
const getQueryText = (path: string, filters?: TopQueriesFilters) => {
2729
const filterConditions = getFiltersConditions(path, filters);
2830
return `
29-
SELECT
31+
SELECT ${QUERY_TECHNICAL_MARK}
3032
CPUTime as CPUTimeUs,
3133
QueryText,
3234
IntervalEnd,
@@ -36,7 +38,7 @@ SELECT
3638
UserSID,
3739
Duration
3840
FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\`
39-
WHERE ${filterConditions || 'true'}
41+
WHERE ${filterConditions || 'true'} AND QueryText NOT LIKE '%${QUERY_TECHNICAL_MARK}%'
4042
ORDER BY CPUTimeUs DESC
4143
`;
4244
};
@@ -98,7 +100,15 @@ export const topQueriesApi = api.injectEndpoints({
98100
? `Query ILIKE '%${filters.text}%' OR UserSID ILIKE '%${filters.text}%'`
99101
: '';
100102

101-
const queryText = `SELECT UserSID, QueryStartAt, Query as QueryText, ApplicationName from \`.sys/query_sessions\` WHERE ${filterConditions || 'true'} ORDER BY SessionStartAt limit 100`;
103+
const queryText = `SELECT ${QUERY_TECHNICAL_MARK}
104+
UserSID, QueryStartAt, Query as QueryText, ApplicationName
105+
FROM
106+
\`.sys/query_sessions\`
107+
WHERE
108+
${filterConditions || 'true'} AND Query NOT LIKE '%${QUERY_TECHNICAL_MARK}%'
109+
ORDER BY
110+
SessionStartAt
111+
LIMIT 100`;
102112

103113
const response = await window.api.sendQuery(
104114
{
@@ -115,13 +125,6 @@ export const topQueriesApi = api.injectEndpoints({
115125

116126
const data = parseQueryAPIExecuteResponse(response);
117127

118-
/* filter running queries query itself */
119-
if (data?.resultSets?.[0]?.result) {
120-
data.resultSets[0].result = data.resultSets[0].result.filter(
121-
(item) => item.QueryText !== queryText,
122-
);
123-
}
124-
125128
return {data};
126129
} catch (error) {
127130
return {error};

0 commit comments

Comments
 (0)