Skip to content

Commit ca3ab2c

Browse files
committed
refactor: improve /describe requests for schema objects
1 parent deaf519 commit ca3ab2c

File tree

12 files changed

+119
-58
lines changed

12 files changed

+119
-58
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import {shallowEqual} from 'react-redux';
55

66
import {ResponseError} from '../../../../components/Errors/ResponseError';
77
import {Loader} from '../../../../components/Loader';
8-
import {describeApi} from '../../../../store/reducers/describe';
8+
import {
9+
overviewApi,
10+
selectPreparedPathOverview,
11+
} from '../../../../store/reducers/overview/overview';
912
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
1013
import type {EPathType} from '../../../../types/api/schema';
1114
import {cn} from '../../../../utils/cn';
@@ -41,14 +44,17 @@ const Describe = ({path, database, type}: IDescribeProps) => {
4144
} else if (mergedChildrenPaths) {
4245
paths = [path, ...mergedChildrenPaths];
4346
}
44-
const {currentData, isFetching, error} = describeApi.useGetDescribeQuery(
47+
const {currentData, isFetching, error} = overviewApi.useGetOverviewQuery(
4548
paths.length ? {paths, database} : skipToken,
4649
{
4750
pollingInterval: autoRefreshInterval,
4851
},
4952
);
5053
const loading = isFetching && currentData === undefined;
51-
const currentDescribe = currentData;
54+
55+
const data = useTypedSelector((state) => selectPreparedPathOverview(state, paths, database));
56+
57+
const currentDescribe = data;
5258

5359
let preparedDescribeData: Object | undefined;
5460
if (currentDescribe) {

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {Button, Card, Icon} from '@gravity-ui/uikit';
88
import {ResponseError} from '../../../../components/Errors/ResponseError';
99
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
1010
import {hotKeysApi} from '../../../../store/reducers/hotKeys/hotKeys';
11-
import {useGetSchemaQuery} from '../../../../store/reducers/schema/schema';
11+
import {overviewApi} from '../../../../store/reducers/overview/overview';
1212
import type {HotKey} from '../../../../types/api/hotkeys';
1313
import {cn} from '../../../../utils/cn';
1414
import {DEFAULT_TABLE_SETTINGS, IS_HOTKEYS_HELP_HIDDEN_KEY} from '../../../../utils/constants';
15-
import {useSetting} from '../../../../utils/hooks';
15+
import {useAutoRefreshInterval, useSetting} from '../../../../utils/hooks';
1616

1717
import i18n from './i18n';
1818

@@ -61,9 +61,17 @@ interface HotKeysProps {
6161
export function HotKeys({path, database}: HotKeysProps) {
6262
const {currentData: data, isFetching, error} = hotKeysApi.useGetHotKeysQuery({path, database});
6363
const loading = isFetching && data === undefined;
64-
65-
const {data: schemaData, isLoading: schemaLoading} = useGetSchemaQuery({path, database});
66-
64+
const [autoRefreshInterval] = useAutoRefreshInterval();
65+
const {currentData, isLoading: schemaLoading} = overviewApi.useGetOverviewQuery(
66+
{
67+
paths: [path],
68+
database,
69+
},
70+
{
71+
pollingInterval: autoRefreshInterval,
72+
},
73+
);
74+
const {data: schemaData} = currentData ?? {};
6775
const keyColumnsIds = schemaData?.PathDescription?.Table?.KeyColumnNames;
6876

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

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import {ResponseError} from '../../../../components/Errors/ResponseError';
77
import {TableIndexInfo} from '../../../../components/InfoViewer/schemaInfo';
88
import {Loader} from '../../../../components/Loader';
99
import {overviewApi} from '../../../../store/reducers/overview/overview';
10-
import {
11-
selectSchemaMergedChildrenPaths,
12-
useGetSchemaQuery,
13-
} from '../../../../store/reducers/schema/schema';
10+
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
1411
import {EPathType} from '../../../../types/api/schema';
1512
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1613
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
@@ -57,8 +54,6 @@ function Overview({type, path, database}: OverviewProps) {
5754
const overviewLoading = isFetching && currentData === undefined;
5855
const {data: rawData, additionalData} = currentData || {};
5956

60-
const {error: schemaError} = useGetSchemaQuery({path, database});
61-
6257
const entityLoading = overviewLoading;
6358
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;
6459

@@ -101,7 +96,6 @@ function Overview({type, path, database}: OverviewProps) {
10196

10297
return (
10398
<React.Fragment>
104-
{schemaError ? <ResponseError error={schemaError} /> : null}
10599
{overviewError ? <ResponseError error={overviewError} /> : null}
106100
{overviewError && !rawData ? null : renderContent()}
107101
</React.Fragment>

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Loader} from '@gravity-ui/uikit';
22

33
import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
4-
import {useGetSchemaQuery} from '../../../../store/reducers/schema/schema';
4+
import {overviewApi} from '../../../../store/reducers/overview/overview';
55
import {TENANT_METRICS_TABS_IDS} from '../../../../store/reducers/tenant/constants';
66
import {tenantApi} from '../../../../store/reducers/tenant/tenant';
77
import {calculateTenantMetrics} from '../../../../store/reducers/tenants/utils';
@@ -44,9 +44,17 @@ export function TenantOverview({
4444
const {Name, Type, Overall} = tenant || {};
4545

4646
const tenantType = mapDatabaseTypeToDBName(Type);
47-
4847
// FIXME: remove after correct data is added to tenantInfo
49-
const {data: tenantSchemaData} = useGetSchemaQuery({path: tenantName, database: tenantName});
48+
const {currentData} = overviewApi.useGetOverviewQuery(
49+
{
50+
paths: [tenantName],
51+
database: tenantName,
52+
},
53+
{
54+
pollingInterval: autoRefreshInterval,
55+
},
56+
);
57+
const {data: tenantSchemaData} = currentData ?? {};
5058
const {Tables, Topics} =
5159
tenantSchemaData?.PathDescription?.DomainDescription?.DiskSpaceUsage || {};
5260

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {InfoViewerItem} from '../../../components/InfoViewer/InfoViewer';
1414
import {LinkWithIcon} from '../../../components/LinkWithIcon/LinkWithIcon';
1515
import SplitPane from '../../../components/SplitPane';
1616
import routes, {createExternalUILink, createHref} from '../../../routes';
17+
import {overviewApi} from '../../../store/reducers/overview/overview';
1718
import {useGetSchemaQuery} from '../../../store/reducers/schema/schema';
1819
import {TENANT_SUMMARY_TABS_IDS} from '../../../store/reducers/tenant/constants';
1920
import {setSummaryTab} from '../../../store/reducers/tenant/tenant';
@@ -27,7 +28,7 @@ import {
2728
formatNumber,
2829
formatSecondsToHours,
2930
} from '../../../utils/dataFormatters/dataFormatters';
30-
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
31+
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
3132
import {Acl} from '../Acl/Acl';
3233
import {EntityTitle} from '../EntityTitle/EntityTitle';
3334
import {SchemaViewer} from '../Schema/SchemaViewer/SchemaViewer';
@@ -77,6 +78,7 @@ export function ObjectSummary({
7778
onExpandSummary,
7879
isCollapsed,
7980
}: ObjectSummaryProps) {
81+
const [autoRefreshInterval] = useAutoRefreshInterval();
8082
const dispatch = useTypedDispatch();
8183
const [, setCurrentPath] = useQueryParam('schema', StringParam);
8284
const [commonInfoVisibilityState, dispatchCommonInfoVisibilityState] = React.useReducer(
@@ -94,7 +96,16 @@ export function ObjectSummary({
9496
ignoreQueryPrefix: true,
9597
});
9698

97-
const {data: currentObjectData} = useGetSchemaQuery({path, database: tenantName});
99+
const {currentData} = overviewApi.useGetOverviewQuery(
100+
{
101+
paths: [path],
102+
database: tenantName,
103+
},
104+
{
105+
pollingInterval: autoRefreshInterval,
106+
},
107+
);
108+
const {data: currentObjectData} = currentData ?? {};
98109
const currentSchemaData = currentObjectData?.PathDescription?.Self;
99110

100111
React.useEffect(() => {

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import {skipToken} from '@reduxjs/toolkit/query';
44

55
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
66
import {TableSkeleton} from '../../../../components/TableSkeleton/TableSkeleton';
7-
import {useGetSchemaQuery} from '../../../../store/reducers/schema/schema';
7+
import {overviewApi} from '../../../../store/reducers/overview/overview';
88
import {viewSchemaApi} from '../../../../store/reducers/viewSchema/viewSchema';
99
import type {EPathType} from '../../../../types/api/schema';
1010
import {DEFAULT_TABLE_SETTINGS} from '../../../../utils/constants';
11+
import {useAutoRefreshInterval} from '../../../../utils/hooks';
1112
import {
1213
isColumnEntityType,
1314
isExternalTableType,
@@ -36,7 +37,18 @@ interface SchemaViewerProps {
3637
}
3738

3839
export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaViewerProps) => {
39-
const {data: schemaData, isLoading: loading} = useGetSchemaQuery({path, database: tenantName});
40+
const [autoRefreshInterval] = useAutoRefreshInterval();
41+
const {currentData, isLoading: loading} = overviewApi.useGetOverviewQuery(
42+
{
43+
paths: [path],
44+
database: tenantName,
45+
},
46+
{
47+
pollingInterval: autoRefreshInterval,
48+
},
49+
);
50+
51+
const {data: schemaData} = currentData ?? {};
4052

4153
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
4254

src/containers/Tenant/Schema/SchemaViewer/prepareData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
TTableDescription,
99
} from '../../../../types/api/schema';
1010
import {EColumnCodec} from '../../../../types/api/schema';
11+
import type {Nullable} from '../../../../utils/typecheckers';
1112
import {isColumnEntityType, isExternalTableType, isRowTableType} from '../../utils/schema';
1213

1314
import type {SchemaData} from './types';
@@ -123,7 +124,7 @@ function prepareColumnTableSchema(data: TColumnTableDescription = {}): SchemaDat
123124

124125
export function prepareSchemaData(
125126
type?: EPathType,
126-
schema?: TEvDescribeSchemeResult,
127+
schema?: Nullable<TEvDescribeSchemeResult>,
127128
): SchemaData[] {
128129
const {Table, ColumnTableDescription, ExternalTableDescription} = schema?.PathDescription || {};
129130

src/containers/Tenant/Tenant.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {PageError, isAccessError} from '../../components/Errors/PageError/PageEr
77
import {LoaderWrapper} from '../../components/LoaderWrapper/LoaderWrapper';
88
import SplitPane from '../../components/SplitPane';
99
import {setHeaderBreadcrumbs} from '../../store/reducers/header/header';
10-
import {useGetSchemaQuery} from '../../store/reducers/schema/schema';
10+
import {overviewApi} from '../../store/reducers/overview/overview';
1111
import type {AdditionalNodesProps, AdditionalTenantsProps} from '../../types/additionalProps';
1212
import {cn} from '../../utils/cn';
1313
import {DEFAULT_IS_TENANT_SUMMARY_COLLAPSED, DEFAULT_SIZE_TENANT_KEY} from '../../utils/constants';
14-
import {useTypedDispatch} from '../../utils/hooks';
14+
import {useAutoRefreshInterval, useTypedDispatch} from '../../utils/hooks';
1515

1616
import ObjectGeneral from './ObjectGeneral/ObjectGeneral';
1717
import {ObjectSummary} from './ObjectSummary/ObjectSummary';
@@ -41,6 +41,7 @@ interface TenantProps {
4141
}
4242

4343
export function Tenant(props: TenantProps) {
44+
const [autoRefreshInterval] = useAutoRefreshInterval();
4445
const [summaryVisibilityState, dispatchSummaryVisibilityAction] = React.useReducer(
4546
paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED),
4647
undefined,
@@ -74,7 +75,13 @@ export function Tenant(props: TenantProps) {
7475

7576
const path = schema ?? tenantName;
7677

77-
const {data: currentItem, error, isLoading} = useGetSchemaQuery({path, database: tenantName});
78+
const {currentData, error, isLoading} = overviewApi.useGetOverviewQuery(
79+
{paths: [path], database: tenantName},
80+
{
81+
pollingInterval: autoRefreshInterval,
82+
},
83+
);
84+
const {data: currentItem} = currentData ?? {};
7885
const {PathType: currentPathType, PathSubType: currentPathSubType} =
7986
currentItem?.PathDescription?.Self || {};
8087

src/services/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
365365
enums: true,
366366
backup: false,
367367
private: true,
368-
partition_config: true,
369-
partition_stats: true,
370-
partitioning_info: true,
368+
partition_config: false,
369+
partition_stats: false,
370+
partitioning_info: false,
371371
subs: 1,
372372
},
373373
{concurrentId, requestConfig: {signal}},

src/store/reducers/describe.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)