mirror of https://github.com/apache/druid.git
fix SQL in segment card (#13895)
This commit is contained in:
parent
fcfb7b8ff6
commit
ca4df85941
|
@ -27,7 +27,7 @@ import { deepGet, pluralIfNeeded, queryDruidSql } from '../../../utils';
|
||||||
import { HomeViewCard } from '../home-view-card/home-view-card';
|
import { HomeViewCard } from '../home-view-card/home-view-card';
|
||||||
|
|
||||||
export interface SegmentCounts {
|
export interface SegmentCounts {
|
||||||
available: number;
|
total: number;
|
||||||
unavailable: number;
|
unavailable: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ export const SegmentsCard = React.memo(function SegmentsCard(props: SegmentsCard
|
||||||
if (capabilities.hasSql()) {
|
if (capabilities.hasSql()) {
|
||||||
const segments = await queryDruidSql({
|
const segments = await queryDruidSql({
|
||||||
query: `SELECT
|
query: `SELECT
|
||||||
COUNT(*) as "available",
|
COUNT(*) as "total",
|
||||||
COUNT(*) FILTER (WHERE is_available = 0) as "unavailable"
|
COUNT(*) FILTER (WHERE is_active = 1 AND is_available = 0) as "unavailable"
|
||||||
FROM sys.segments`,
|
FROM sys.segments`,
|
||||||
});
|
});
|
||||||
return segments.length === 1 ? segments[0] : null;
|
return segments.length === 1 ? segments[0] : null;
|
||||||
|
@ -60,7 +60,7 @@ FROM sys.segments`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
available: availableSegmentNum + unavailableSegmentNum,
|
total: availableSegmentNum + unavailableSegmentNum,
|
||||||
unavailable: unavailableSegmentNum,
|
unavailable: unavailableSegmentNum,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,7 +70,7 @@ FROM sys.segments`,
|
||||||
initQuery: props.capabilities,
|
initQuery: props.capabilities,
|
||||||
});
|
});
|
||||||
|
|
||||||
const segmentCount = segmentCountState.data || { available: 0, unavailable: 0 };
|
const segmentCount = segmentCountState.data || { total: 0, unavailable: 0 };
|
||||||
return (
|
return (
|
||||||
<HomeViewCard
|
<HomeViewCard
|
||||||
className="segments-card"
|
className="segments-card"
|
||||||
|
@ -80,7 +80,7 @@ FROM sys.segments`,
|
||||||
loading={segmentCountState.loading}
|
loading={segmentCountState.loading}
|
||||||
error={segmentCountState.error}
|
error={segmentCountState.error}
|
||||||
>
|
>
|
||||||
<p>{pluralIfNeeded(segmentCount.available, 'segment')}</p>
|
<p>{pluralIfNeeded(segmentCount.total, 'segment')}</p>
|
||||||
{Boolean(segmentCount.unavailable) && (
|
{Boolean(segmentCount.unavailable) && (
|
||||||
<p>{pluralIfNeeded(segmentCount.unavailable, 'unavailable segment')}</p>
|
<p>{pluralIfNeeded(segmentCount.unavailable, 'unavailable segment')}</p>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue