Skip to content

Commit 9ab1f81

Browse files
github-actions[bot]Kishore Kumaar Natarajan
and
Kishore Kumaar Natarajan
committed
Fix duplicated requests on refreshing the overview (#138) (#141)
* Duplicated requests on refreshing the overview * updated unit test --------- (cherry picked from commit c8d7ff5) Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kishore Kumaar Natarajan <[email protected]> (cherry picked from commit 2c39703) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4b371f8 commit 9ab1f81

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

public/pages/TopNQueries/TopNQueries.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe('TopNQueries Component', () => {
209209
);
210210
// Verify that the component re-fetches data for the new time range
211211
await waitFor(() => {
212-
expect(mockCore.http.get).toHaveBeenCalledTimes(16);
212+
expect(mockCore.http.get).toHaveBeenCalledTimes(7);
213213
expect(mockCore.http.get).toHaveBeenCalledWith('/api/settings', expect.any(Object));
214214
expect(mockCore.http.get).toHaveBeenCalledWith(
215215
'/api/top_queries/latency',

public/pages/TopNQueries/TopNQueries.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ const TopNQueries = ({
163163
// TODO: refactor retrieveQueries and retrieveConfigInfo into a Util function
164164
const retrieveQueries = useCallback(
165165
async (start: string, end: string) => {
166+
if (loading) return;
167+
setLoading(true);
166168
const nullResponse = { response: { top_queries: [] } };
167169
const apiParams = {
168170
query: {
@@ -190,7 +192,6 @@ const TopNQueries = ({
190192
}
191193
};
192194
try {
193-
setLoading(true);
194195
const respLatency = latencySettings.isEnabled
195196
? await fetchMetric('/api/top_queries/latency')
196197
: nullResponse;

0 commit comments

Comments
 (0)