Skip to content

fix(HealthcheckPreview): use only one query #2427

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

Merged
merged 1 commit into from
Jun 19, 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: 1 addition & 7 deletions src/containers/Tenant/Diagnostics/Diagnostics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,7 @@ function Diagnostics(props: DiagnosticsProps) {
}}
allowNotSelected={true}
/>
<AutoRefreshControl
onManualRefresh={() => {
//this is needed to collect healthcheck if it is disabled by default https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
const event = new CustomEvent('diagnosticsRefresh');
document.dispatchEvent(event);
}}
/>
<AutoRefreshControl />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import type {AlertProps} from '@gravity-ui/uikit';
import {Alert, Button, Flex, Icon, Popover, Skeleton} from '@gravity-ui/uikit';

Expand Down Expand Up @@ -52,36 +50,12 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
{
//FIXME https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
pollingInterval: healthcheckPreviewDisabled ? undefined : autoRefreshInterval,
skip: healthcheckPreviewDisabled,
},
);

const [getHealthcheckQuery, {currentData: manualData, isFetching: isFetchingManually}] =
healthcheckApi.useLazyGetHealthcheckInfoQuery();

React.useEffect(() => {
if (healthcheckPreviewDisabled) {
getHealthcheckQuery({database: tenantName});
}
}, [healthcheckPreviewDisabled, tenantName, getHealthcheckQuery]);
const loading = isFetching && data === undefined;

React.useEffect(() => {
const fetchHealthcheck = () => {
if (healthcheckPreviewDisabled) {
getHealthcheckQuery({database: tenantName});
}
};
document.addEventListener('diagnosticsRefresh', fetchHealthcheck);
return () => {
document.removeEventListener('diagnosticsRefresh', fetchHealthcheck);
};
}, [tenantName, healthcheckPreviewDisabled, getHealthcheckQuery]);

const loading =
(isFetching && data === undefined) || (isFetchingManually && manualData === undefined);

const selfCheckResult: SelfCheckResult =
data?.self_check_result || manualData?.self_check_result || SelfCheckResult.UNSPECIFIED;
const selfCheckResult: SelfCheckResult = data?.self_check_result || SelfCheckResult.UNSPECIFIED;

const modifier = selfCheckResult.toLowerCase();

Expand Down
Loading