Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

disable warehouse tenant query when ff is disabled (#26873)

Jordi Enric483492564d75
diff --git a/apps/studio/components/interfaces/DataWarehouse/WarehouseCollectionDetail.tsx b/apps/studio/components/interfaces/DataWarehouse/WarehouseCollectionDetail.tsx
index bc688d522ce..ca9daaa04ee 100644
--- a/apps/studio/components/interfaces/DataWarehouse/WarehouseCollectionDetail.tsx
+++ b/apps/studio/components/interfaces/DataWarehouse/WarehouseCollectionDetail.tsx
@@ -14,6 +14,7 @@ import { TestCollectionDialog } from './TestCollectionDialog'
import { RefreshCcw, Rewind } from 'lucide-react'
import AlertError from 'components/ui/AlertError'
import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
+import { useFlag } from 'hooks'
export const WarehouseCollectionDetail = () => {
const router = useRouter()
@@ -21,10 +22,11 @@ export const WarehouseCollectionDetail = () => {
const projectRef = router.query.ref as string
const accessTokens = useWarehouseAccessTokensQuery({ projectRef })
const [testDialogOpen, setTestDialogOpen] = useState(false)
+ const hasWarehouse = useFlag('warehouse')
const { data: collections, isLoading: collectionsLoading } = useWarehouseCollectionsQuery(
{ projectRef },
- { enabled: true }
+ { enabled: hasWarehouse }
)
const collection = (collections || []).find((c) => c.token === collectionToken)
const [params, setParams] = useState({
@@ -58,7 +60,7 @@ export const WarehouseCollectionDetail = () => {
} = useWarehouseQueryQuery(
{ ref: projectRef, sql: params.sql },
{
- enabled: !!params.sql,
+ enabled: !!params.sql && hasWarehouse,
}
)
diff --git a/apps/studio/components/interfaces/Settings/Logs/LogSelection.tsx b/apps/studio/components/interfaces/Settings/Logs/LogSelection.tsx
index 59fda811dae..ded083ee1ed 100644
--- a/apps/studio/components/interfaces/Settings/Logs/LogSelection.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/LogSelection.tsx
@@ -56,6 +56,7 @@ const LogSelection = ({
sql,
},
{
+ enabled: queryType === 'warehouse',
onError: (error) => {
toast.error(error.message)
},
@@ -70,7 +71,9 @@ const LogSelection = ({
}, [collectionName, partialLog?.id])
useEffect(() => {
- refetchWarehouseData()
+ if (queryType === 'warehouse') {
+ refetchWarehouseData()
+ }
}, [warehouseQueryData, collectionName, projectRef, partialLog?.id, refetchWarehouseData])
const Formatter = () => {
@@ -208,7 +211,7 @@ const LogSelection = ({
</div>
<div className="h-px w-full bg-selection rounded " />
</div>
- {(isLoading || warehouseQueryLoading) && <Loading />}
+ {isLoading && <Loading />}
<div className="flex flex-col space-y-6 bg-surface-100 py-4">
{!isLoading && <Formatter />}
</div>
diff --git a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
index 473090be483..e95f8d1f50b 100644
--- a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
+++ b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
@@ -41,7 +41,12 @@ const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) =>
const { ref } = useParams()
const projectRef = ref || 'default'
- const { data: tenant } = useWarehouseTenantQuery({ projectRef })
+ const { data: tenant } = useWarehouseTenantQuery(
+ { projectRef },
+ {
+ enabled: showWarehouse,
+ }
+ )
const { data: collections, isLoading: collectionsLoading } = useWarehouseCollectionsQuery(
{
projectRef: !tenant ? 'undefined' : projectRef,
diff --git a/apps/studio/data/analytics/warehouse-query.ts b/apps/studio/data/analytics/warehouse-query.ts
index cf5cf31571b..b62e1e319c9 100644
--- a/apps/studio/data/analytics/warehouse-query.ts
+++ b/apps/studio/data/analytics/warehouse-query.ts
@@ -34,16 +34,13 @@ export type WarehouseQueryError = ResponseError
export const useWarehouseQueryQuery = <TData = WarehouseQueryData>(
{ ref, sql }: WarehouseQueryVariables,
- {
- enabled = true,
- ...options
- }: UseQueryOptions<WarehouseQueryData, WarehouseQueryError, TData> = {}
+ { enabled, ...options }: UseQueryOptions<WarehouseQueryData, WarehouseQueryError, TData> = {}
) =>
useQuery<WarehouseQueryData, WarehouseQueryError, TData>(
analyticsKeys.warehouseQuery(ref, sql),
({ signal }) => getWarehouseQuery({ ref, sql }, signal),
{
- enabled: enabled && typeof ref !== 'undefined',
+ enabled,
staleTime: Infinity,
cacheTime: 15 * 60 * 1000, // 15 mins cache time
refetchOnMount: false,