Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Fix duplicated requests on refreshing the overview #141

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/pages/TopNQueries/TopNQueries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('TopNQueries Component', () => {
);
// Verify that the component re-fetches data for the new time range
await waitFor(() => {
expect(mockCore.http.get).toHaveBeenCalledTimes(16);
expect(mockCore.http.get).toHaveBeenCalledTimes(7);
expect(mockCore.http.get).toHaveBeenCalledWith('/api/settings', expect.any(Object));
expect(mockCore.http.get).toHaveBeenCalledWith(
'/api/top_queries/latency',
Expand Down
3 changes: 2 additions & 1 deletion public/pages/TopNQueries/TopNQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ const TopNQueries = ({
// TODO: refactor retrieveQueries and retrieveConfigInfo into a Util function
const retrieveQueries = useCallback(
async (start: string, end: string) => {
if (loading) return;
setLoading(true);
const nullResponse = { response: { top_queries: [] } };
const apiParams = {
query: {
Expand Down Expand Up @@ -190,7 +192,6 @@ const TopNQueries = ({
}
};
try {
setLoading(true);
const respLatency = latencySettings.isEnabled
? await fetchMetric('/api/top_queries/latency')
: nullResponse;
Expand Down
Loading