Skip to content

Commit bc6c4cb

Browse files
KishoreKicha14Kishore Kumaar Natarajan
and
Kishore Kumaar Natarajan
authored
[Improvement] remove duplicate requests on overview page loading (#179)
* Bug-fix Duplicate Request on page load Signed-off-by: Kishore Kumaar Natarajan <[email protected]> * bug fix Signed-off-by: Kishore Kumaar Natarajan <[email protected]> * Added mock RetrieveQueries Signed-off-by: Kishore Kumaar Natarajan <[email protected]> * Added mock RetrieveQueries Signed-off-by: Kishore Kumaar Natarajan <[email protected]> --------- Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Co-authored-by: Kishore Kumaar Natarajan <[email protected]>
1 parent 0a614ec commit bc6c4cb

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

public/pages/QueryInsights/QueryInsights.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const mockDataSourceContext = {
3333

3434
const sampleQueries = MockQueries();
3535

36+
const mockRetrieveQueries = jest.fn();
37+
3638
const renderQueryInsights = () =>
3739
render(
3840
<MemoryRouter>
@@ -44,6 +46,7 @@ const renderQueryInsights = () =>
4446
recentlyUsedRanges={[]}
4547
currStart="now-15m"
4648
currEnd="now"
49+
retrieveQueries={mockRetrieveQueries}
4750
// @ts-ignore
4851
core={mockCore}
4952
depsStart={{ navigation: {} }}

public/pages/QueryInsights/QueryInsights.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ const QueryInsights = ({
379379

380380
const onRefresh = async ({ start, end }: { start: string; end: string }) => {
381381
onTimeChange({ start, end });
382+
retrieveQueries(start, end);
382383
};
383384

384385
const filterDuplicates = (options: any[]) =>

public/pages/TopNQueries/TopNQueries.test.tsx

Lines changed: 1 addition & 1 deletion
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(7);
212+
expect(mockCore.http.get).toHaveBeenCalledTimes(4);
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ const TopNQueries = ({
351351
setEnd(end);
352352
setRecentlyUsedRanges(usedRange.length > 10 ? usedRange.slice(0, 9) : usedRange);
353353
retrieveConfigInfo(true);
354-
retrieveQueries(start, end);
355354
};
356355

357356
useEffect(() => {

0 commit comments

Comments
 (0)