From c907da5376fcbb23d34d46d9baf26b253bae464a Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Fri, 20 Jun 2025 17:58:15 +0800 Subject: [PATCH] Update QueryOptions.ts --- .../interfaces/UnifiedLogs/QueryOptions.ts | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/studio/components/interfaces/UnifiedLogs/QueryOptions.ts b/apps/studio/components/interfaces/UnifiedLogs/QueryOptions.ts index 4bc978188f4..0309e23561f 100644 --- a/apps/studio/components/interfaces/UnifiedLogs/QueryOptions.ts +++ b/apps/studio/components/interfaces/UnifiedLogs/QueryOptions.ts @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query' import dayjs from 'dayjs' import { ARRAY_DELIMITER, SORT_DELIMITER } from 'components/ui/DataTable/DataTable.constants' -import { get } from 'data/fetchers' +import { get, post } from 'data/fetchers' import { getLogsChartQuery, getLogsCountQuery, getUnifiedLogsQuery } from './UnifiedLogs.queries' import { BaseChartSchema, ColumnSchema, type FacetMetadataSchema } from './UnifiedLogs.schema' import type { PageParam, SearchParamsType, UnifiedLogsMeta } from './UnifiedLogs.types' @@ -117,18 +117,23 @@ export const useChartData = (search: SearchParamsType, projectRef: string) => { // Get SQL query from utility function (with dynamic bucketing) const sql = getLogsChartQuery(search) - // Use the get function from data/fetchers for chart data - const { data, error } = await get(`/platform/projects/{ref}/analytics/endpoints/logs.all`, { - params: { - path: { ref: projectRef }, - query: { - iso_timestamp_start: dateStart, - iso_timestamp_end: dateEnd, - project: projectRef, + // Use the post function from data/fetchers for chart data + const { data, error } = await post( + `/platform/projects/{ref}/analytics/endpoints/logs.all`, + { + params: { + path: { ref: projectRef }, + query: { + iso_timestamp_start: dateStart, + iso_timestamp_end: dateEnd, + project: projectRef, + }, + }, + body: { sql, }, - }, - }) + } + ) if (error) { if (DEBUG_MODE) console.error('API returned error for chart data:', error) @@ -314,7 +319,7 @@ export const dataOptions = (search: SearchParamsType, projectRef: string) => { const countsSql = getLogsCountQuery(search) // First, fetch the counts data - const { data: countsData, error: countsError } = await get( + const { data: countsData, error: countsError } = await post( `/platform/projects/{ref}/analytics/endpoints/logs.all`, { params: { @@ -323,9 +328,11 @@ export const dataOptions = (search: SearchParamsType, projectRef: string) => { iso_timestamp_start: isoTimestampStart, iso_timestamp_end: isoTimestampEnd, project: projectRef, - sql: countsSql, }, }, + body: { + sql: countsSql, + }, } ) @@ -412,7 +419,7 @@ export const dataOptions = (search: SearchParamsType, projectRef: string) => { console.log('🔍 Raw pageParam received:', pageParam) } - const { data: logsData, error: logsError } = await get( + const { data: logsData, error: logsError } = await post( `/platform/projects/{ref}/analytics/endpoints/logs.all`, { params: { @@ -421,9 +428,11 @@ export const dataOptions = (search: SearchParamsType, projectRef: string) => { iso_timestamp_start: timestampStart, iso_timestamp_end: timestampEnd, project: projectRef, - sql: logsSql, }, }, + body: { + sql: logsSql, + }, } )