From a4eb67cdba593cc8e945159d0522010e143bbbdc Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Sat, 9 Apr 2022 02:35:10 +0800 Subject: [PATCH] fix: restrict how many requests are made by app to api when no sql is present for logs request --- studio/hooks/analytics/useLogsPreview.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/studio/hooks/analytics/useLogsPreview.tsx b/studio/hooks/analytics/useLogsPreview.tsx index e8d6bd8eaed..81125d0cbf9 100644 --- a/studio/hooks/analytics/useLogsPreview.tsx +++ b/studio/hooks/analytics/useLogsPreview.tsx @@ -61,6 +61,13 @@ function useLogsPreview( // handle url generation for log pagination const getKeyLogs: SWRInfiniteKeyLoader = (_pageIndex: number, prevPageData: Logs) => { let queryParams + + // check that SQL is ready for the logs request + if(!params.sql || !params.rawSql) { + // return empty url to restrict unnecessary requests to api + return '' + } + // if prev page data is 100 items, could possibly have more records that are not yet fetched within this interval if (prevPageData === null) { // reduce interval window limit by using the timestamp of the last log