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';
|
||||
|
||||
export interface SegmentCounts {
|
||||
available: number;
|
||||
total: number;
|
||||
unavailable: number;
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,8 @@ export const SegmentsCard = React.memo(function SegmentsCard(props: SegmentsCard
|
|||
if (capabilities.hasSql()) {
|
||||
const segments = await queryDruidSql({
|
||||
query: `SELECT
|
||||
COUNT(*) as "available",
|
||||
COUNT(*) FILTER (WHERE is_available = 0) as "unavailable"
|
||||
COUNT(*) as "total",
|
||||
COUNT(*) FILTER (WHERE is_active = 1 AND is_available = 0) as "unavailable"
|
||||
FROM sys.segments`,
|
||||
});
|
||||
return segments.length === 1 ? segments[0] : null;
|
||||
|
@ -60,7 +60,7 @@ FROM sys.segments`,
|
|||
);
|
||||
|
||||
return {
|
||||
available: availableSegmentNum + unavailableSegmentNum,
|
||||
total: availableSegmentNum + unavailableSegmentNum,
|
||||
unavailable: unavailableSegmentNum,
|
||||
};
|
||||
} else {
|
||||
|
@ -70,7 +70,7 @@ FROM sys.segments`,
|
|||
initQuery: props.capabilities,
|
||||
});
|
||||
|
||||
const segmentCount = segmentCountState.data || { available: 0, unavailable: 0 };
|
||||
const segmentCount = segmentCountState.data || { total: 0, unavailable: 0 };
|
||||
return (
|
||||
<HomeViewCard
|
||||
className="segments-card"
|
||||
|
@ -80,7 +80,7 @@ FROM sys.segments`,
|
|||
loading={segmentCountState.loading}
|
||||
error={segmentCountState.error}
|
||||
>
|
||||
<p>{pluralIfNeeded(segmentCount.available, 'segment')}</p>
|
||||
<p>{pluralIfNeeded(segmentCount.total, 'segment')}</p>
|
||||
{Boolean(segmentCount.unavailable) && (
|
||||
<p>{pluralIfNeeded(segmentCount.unavailable, 'unavailable segment')}</p>
|
||||
)}
|
||||
|
|
Loading…
Reference in New Issue