Skip to content

Commit ca6b640

Browse files
authored
feat(6482): Message separately if graph subquery hits limit (#6507)
* feat(6482): Message separately if graph subquery hits limit * feat(6482): add percentage slider to smoothing * fix(6482): move anonymous handler declaration outside of component
1 parent fe624e0 commit ca6b640

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed

src/dataExplorer/components/Results.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ const GraphHeader: FC = () => {
299299
titleText = 'Graph customization options returned no data'
300300
}
301301

302+
const GraphQueryStat = () => (
303+
<div className="query-stat" data-testid="query-stat">
304+
{subQueryResult?.truncated ? (
305+
<span className="query-stat--bold">{`Max. display limit exceeded. Result truncated to ${bytesFormatter(
306+
subQueryResult.bytes
307+
)}.`}</span>
308+
) : null}
309+
</div>
310+
)
311+
302312
return (
303313
<>
304314
<ViewTypeDropdown
@@ -315,6 +325,7 @@ const GraphHeader: FC = () => {
315325
titleText={titleText}
316326
className="de-config-visualization-button"
317327
/>
328+
<GraphQueryStat />
318329
</>
319330
)
320331
}

src/dataExplorer/components/SqlViewOptions.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ComponentStatus,
66
FlexBox,
77
Grid,
8+
RangeSlider,
89
SlideToggle,
910
} from '@influxdata/clockface'
1011

@@ -40,6 +41,11 @@ export const SqlViewOptions: FC<SqlViewOptionsT> = ({
4041
}
4142
}
4243

44+
const handleSmoothingRangeSlider = event =>
45+
selectViewOptions({
46+
smoothing: {percentageRetained: parseInt(event.target.value)},
47+
})
48+
4349
const groupbyTooltipContents = (
4450
<div>
4551
<span>Select the GROUPBY used for the graph subquery.</span>
@@ -126,6 +132,15 @@ export const SqlViewOptions: FC<SqlViewOptionsT> = ({
126132
multiSelect={false}
127133
disabled={!selectedViewOptions?.smoothing?.applied}
128134
/>
135+
<RangeSlider
136+
value={selectedViewOptions?.smoothing?.percentageRetained}
137+
min={5}
138+
max={100}
139+
step={5}
140+
onChange={handleSmoothingRangeSlider}
141+
labelPrefix="retained "
142+
labelSuffix="%"
143+
/>
129144
<div className="sql-view-options--see-query">
130145
<Button
131146
testID="sql-view-options--see-query"

src/dataExplorer/context/results/childResults.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ const modifiersToApply = (viewOptions: ViewOptions): SqlQueryModifiers => {
3535
viewOptions.smoothing?.columns?.length > 0 && viewOptions.smoothing?.applied
3636
if (shouldSmooth) {
3737
prepend.push(`import "experimental/polyline"`)
38+
// will error if give 100.0 --> so instead do 99.9
39+
const percentage = Number(
40+
viewOptions.smoothing.percentageRetained ?? 50
41+
).toFixed(1)
3842
append.push(
39-
`|> polyline.rdp(valColumn: "${viewOptions.smoothing.columns[0]}", timeColumn: "time")`
43+
`|> polyline.rdp(
44+
valColumn: "${viewOptions.smoothing.columns[0]}",
45+
timeColumn: "${viewOptions.smoothing.timeColumn ?? 'time'}",
46+
retention: ${percentage === '100.0' ? '99.9' : percentage}
47+
)`
4048
)
4149
}
4250

src/dataExplorer/context/resultsView.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ import React, {
88
} from 'react'
99
import {useDispatch} from 'react-redux'
1010

11-
import {useSessionStorage} from 'src/dataExplorer/shared/utils'
11+
// Components & Contexts
12+
import {SUPPORTED_VISUALIZATIONS} from 'src/visualization'
13+
import {ResultsContext} from 'src/dataExplorer/context/results'
14+
15+
// Types & Constants
1216
import {
1317
RecursivePartial,
1418
SimpleTableViewProperties,
1519
ViewProperties,
1620
} from 'src/types'
17-
import {SUPPORTED_VISUALIZATIONS} from 'src/visualization'
18-
import {ResultsContext} from 'src/dataExplorer/context/results'
21+
22+
// Utils
1923
import {notify} from 'src/shared/actions/notifications'
2024
import {trySmoothingData} from 'src/shared/copy/notifications'
25+
import {useSessionStorage} from 'src/dataExplorer/shared/utils'
2126

2227
const DEFAULT_TIME_COLUMN = '_time' // unpivoted data
2328
const DEFAULT_DATA_COLUMN = '_value' // unpivoted data
@@ -48,6 +53,8 @@ export interface ViewOptions {
4853
smoothing: {
4954
columns: string[] // currently `|> polyling.rdp()` is applied to a single column, but is not a fundamental requirement
5055
applied: boolean
56+
percentageRetained: number
57+
timeColumn: string
5158
}
5259
}
5360

@@ -76,7 +83,12 @@ interface ResultsViewContextType {
7683

7784
const DEFAULT_VIEW_OPTIONS: ViewOptions = {
7885
groupby: [],
79-
smoothing: {columns: [], applied: true},
86+
smoothing: {
87+
columns: [],
88+
applied: true,
89+
percentageRetained: 50,
90+
timeColumn: 'time',
91+
},
8092
}
8193

8294
const DEFAULT_STATE: ResultsViewContextType = {
@@ -274,11 +286,12 @@ export const ResultsViewProvider: FC = ({children}) => {
274286
const numericColumns = getNumericSelectorColumns()
275287
// initial selection
276288
const defaultSmoothingColumn = defineDefaultUnpivotedColumn(numericColumns)
289+
const timeColumn = defineTimeColumn()
277290

278291
return {
279292
all: {smoothing: {columns: numericColumns}},
280293
selected: {
281-
smoothing: {columns: [defaultSmoothingColumn]},
294+
smoothing: {columns: [defaultSmoothingColumn], timeColumn},
282295
},
283296
}
284297
}

0 commit comments

Comments
 (0)