Skip to content

Commit

Permalink
fix: unhandled tmpl variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Kav91 committed Nov 9, 2023
1 parent 3831412 commit 72b025c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion visualizations/shared/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const subVariables = (query, variables) => {
if (Object.keys(variables).length > 0) {
if (variables && Object.keys(variables || {}).length > 0) {
let newQuery = query;

Object.keys(variables).forEach(varKey => {
Expand Down
18 changes: 8 additions & 10 deletions visualizations/status-table/status-table-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function StatusTableWidget(props) {
const nerdletContext = useContext(NerdletStateContext);
const { filters, selectedVariables } = nerdletContext;
const [nrdbResult, setNrdbResult] = useSetState(null);
const [finalQuery, setQuery] = useState('');
const [finalQuery, setQuery] = useState(null);
const [inputErrors, setInputErrors] = useState([]);
const filterClause = filters ? `WHERE ${filters}` : '';

Expand All @@ -83,19 +83,14 @@ export default function StatusTableWidget(props) {

const inputErrors = discoverErrors(props);
setInputErrors(inputErrors);
}, [query, selectedVariables, enableFilters, filterClause, timeRange]);

useEffect(() => {
fetchData();
interval.stop();
interval.start();
return interval.stop;
}, [
pollInterval,
query,
selectedVariables,
enableFilters,
filterClause,
timeRange
]);
}, [finalQuery, pollInterval]);

const interval = useInterval(() => {
fetchData();
Expand Down Expand Up @@ -251,7 +246,10 @@ export default function StatusTableWidget(props) {

// handle nested percentiles and values that are returned as json and not a flat number
// eg.{ "90": 5600 }
if (Object.keys(firstValue).length > 0) {
if (
typeof firstValue === 'object' &&
Object.keys(firstValue || {}).length > 0
) {
firstValue = firstValue[Object.keys(firstValue)[0]];
}

Expand Down

0 comments on commit 72b025c

Please sign in to comment.