Skip to content

Commit 548ce2f

Browse files
authored
feat: dont fetch render for false graphshard (#2803)
1 parent ed9375e commit 548ce2f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/components/QueriesActivityBar/useQueriesActivityData.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
22

3+
import {selectGraphShardExists} from '../../store/reducers/capabilities/capabilities';
34
import {topQueriesApi} from '../../store/reducers/executeTopQueries/executeTopQueries';
45
import type {KeyValueRow} from '../../types/api/query';
56
import {useAutoRefreshInterval} from '../../utils/hooks';
7+
import {useTypedSelector} from '../../utils/hooks/useTypedSelector';
68
import type {TimeFrame} from '../../utils/timeframes';
79
import {chartApi} from '../MetricChart/reducer';
810

@@ -26,6 +28,10 @@ export function useQueriesActivityData(tenantName: string): UseQueriesActivityDa
2628

2729
const shouldRefresh = autoRefreshInterval;
2830

31+
// Respect GraphShardExists if explicitly false for the specific tenant
32+
const graphShardExists = useTypedSelector((state) => selectGraphShardExists(state, tenantName));
33+
const skipCharts = graphShardExists === false;
34+
2935
const {data: runningQueriesData} = topQueriesApi.useGetRunningQueriesQuery(
3036
{
3137
database: tenantName,
@@ -45,7 +51,7 @@ export function useQueriesActivityData(tenantName: string): UseQueriesActivityDa
4551
timeFrame: QUERIES_TIME_FRAME,
4652
maxDataPoints: 30,
4753
},
48-
{pollingInterval: shouldRefresh},
54+
{pollingInterval: shouldRefresh, skip: skipCharts},
4955
);
5056

5157
const {data: latencyData} = chartApi.useGetChartDataQuery(
@@ -55,21 +61,24 @@ export function useQueriesActivityData(tenantName: string): UseQueriesActivityDa
5561
timeFrame: LATENCIES_TIME_FRAME,
5662
maxDataPoints: 30,
5763
},
58-
{pollingInterval: shouldRefresh},
64+
{pollingInterval: shouldRefresh, skip: skipCharts},
5965
);
6066

6167
const runningQueriesCount = runningQueriesData?.resultSets?.[0]?.result?.length || 0;
6268

6369
// Determine chart availability from queries API success/error state
6470
const areChartsAvailable = React.useMemo(() => {
71+
if (skipCharts) {
72+
return false;
73+
}
6574
if (queriesSuccess) {
6675
return true;
6776
}
6877
if (queriesError) {
6978
return false;
7079
}
7180
return null; // Still loading
72-
}, [queriesSuccess, queriesError]);
81+
}, [queriesSuccess, queriesError, skipCharts]);
7382

7483
const qps = React.useMemo(
7584
() => calculateQueriesPerSecond(queriesPerSecData?.metrics?.[0]?.data),

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
4242
// Refetch data only if dashboard successfully loaded
4343
const shouldRefresh = isDashboardHidden ? 0 : autoRefreshInterval;
4444

45+
// Do not render charts at all when GraphShard capability explicitly says it's absent
46+
if (graphShardExists === false) {
47+
return null;
48+
}
49+
4550
/**
4651
* Charts should be hidden, if they are not enabled:
4752
* 1. GraphShard is not enabled
4853
* 2. ydb version does not have /viewer/json/render endpoint (400, 404, CORS error, etc.)
4954
*
5055
* If at least one chart successfully loaded, dashboard should be shown
5156
* This fallback behavior is only used when GraphShardExists capability is not available or false
52-
* @link https://github.com/ydb-platform/ydb-embedded-ui/issues/659
57+
* Link: https://github.com/ydb-platform/ydb-embedded-ui/issues/659
5358
* @todo disable only for specific errors ('GraphShard is not enabled') after ydb-stable-24 is generally used
5459
*/
5560
const handleChartDataStatusChange = (chartStatus: ChartDataStatus) => {

0 commit comments

Comments
 (0)