Skip to content

Commit

Permalink
Add conditional fetching of aggregated results in MetricView based on…
Browse files Browse the repository at this point in the history
… hideQueryElements prop
  • Loading branch information
simlarsen committed Nov 26, 2024
1 parent 488a2b0 commit 680be0e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Dashboard/src/Components/Metrics/MetricView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ const MetricView: FunctionComponent<ComponentProps> = (
setCharts(getCharts());
}, []);

useEffect(() => {
if (
props.hideQueryElements &&
metricViewData &&
metricViewData.startAndEndDate &&
metricViewData.startAndEndDate.startValue &&
metricViewData.startAndEndDate.endValue
) {
fetchAggregatedResults().catch((err: Error) => {
setMetricResultsError(API.getFriendlyErrorMessage(err as Error));
});
}
}, [metricViewData]);

const [metricResults, setMetricResults] = useState<Array<AggregatedResult>>(
[],
);
Expand Down Expand Up @@ -502,20 +516,6 @@ const MetricView: FunctionComponent<ComponentProps> = (
...metricViewData,
startAndEndDate: startAndEndDate,
});

// if hideQueryElements is true then we should fetch the results immediately because apply button is hidden
if (
props.hideQueryElements &&
startAndEndDate &&
startAndEndDate.startValue &&
startAndEndDate.endValue
) {
fetchAggregatedResults().catch((err: Error) => {
setMetricResultsError(
API.getFriendlyErrorMessage(err as Error),
);
});
}
}}
/>
</div>
Expand Down

0 comments on commit 680be0e

Please sign in to comment.