fix: restrict how many requests are made by app to api when no sql is present for logs request

This commit is contained in:
Jonathan Summers-Muir authored and Ziinc committed 2022-04-11 14:16:00 +02:00
1 parent 0e88f9f1a7
commit a4eb67cdba
1 file changed
+7
@@ -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