fix refresh button (#9195)

This commit is contained in:
Vadim Ogievetsky 2020-01-16 10:13:47 -08:00 committed by GitHub
parent 92ac22d060
commit 09efd20b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 15 deletions

View File

@ -224,7 +224,7 @@ export class SegmentsView extends React.PureComponent<SegmentsViewProps, Segment
` "segment_id", "datasource", "start", "end", "size", "version", "partition_num", "num_replicas", "num_rows", "is_published", "is_available", "is_realtime", "is_overshadowed", "payload"`,
`FROM sys.segments`,
`WHERE`,
` ("start" || '/' || "end") IN (${intervals})`,
intervals ? ` ("start" || '/' || "end") IN (${intervals})` : 'FALSE',
whereClause ? ` AND ${whereClause}` : '',
]);
@ -311,16 +311,14 @@ export class SegmentsView extends React.PureComponent<SegmentsViewProps, Segment
}),
);
const results: SegmentQueryResultRow[] = nestedResults.flat().sort((d1: any, d2: any) => {
return nestedResults.flat().sort((d1: any, d2: any) => {
return d2.start.localeCompare(d1.start);
});
return results.slice(0, SegmentsView.PAGE_SIZE);
},
onStateChange: ({ result, loading, error }) => {
this.setState({
allSegments: result,
segments: result,
segments: result ? result.slice(0, SegmentsView.PAGE_SIZE) : undefined,
segmentsLoading: loading,
segmentsError: error,
});
@ -360,6 +358,11 @@ export class SegmentsView extends React.PureComponent<SegmentsViewProps, Segment
const sortPivot = sorted[0].id;
const sortDesc = sorted[0].desc;
const selectedSegments = allSegments
.filter((d: any) => {
return filtered.every((f: any) => {
return d[f.id].includes(f.value);
});
})
.sort((d1: any, d2: any) => {
const v1 = d1[sortPivot];
const v2 = d2[sortPivot];
@ -369,14 +372,10 @@ export class SegmentsView extends React.PureComponent<SegmentsViewProps, Segment
return sortDesc ? v2 - v1 : v1 - v2;
}
})
.filter((d: any) => {
return filtered.every((f: any) => {
return d[f.id].includes(f.value);
});
});
const segments = selectedSegments.slice(startPage, endPage);
.slice(startPage, endPage);
this.setState({
segments,
segments: selectedSegments,
});
};
@ -683,9 +682,9 @@ export class SegmentsView extends React.PureComponent<SegmentsViewProps, Segment
<ViewControlBar label="Segments">
<RefreshButton
onRefresh={auto =>
capabilities
? this.segmentsNoSqlQueryManager.rerunLastQuery(auto)
: this.segmentsSqlQueryManager.rerunLastQuery(auto)
capabilities.hasSql()
? this.segmentsSqlQueryManager.rerunLastQuery(auto)
: this.segmentsNoSqlQueryManager.rerunLastQuery(auto)
}
localStorageKey={LocalStorageKeys.SEGMENTS_REFRESH_RATE}
/>