diff --git a/apps/studio/components/interfaces/Home/ServiceStatus.tsx b/apps/studio/components/interfaces/Home/ServiceStatus.tsx index 7f610fabb2..2d0699bfed 100644 --- a/apps/studio/components/interfaces/Home/ServiceStatus.tsx +++ b/apps/studio/components/interfaces/Home/ServiceStatus.tsx @@ -5,7 +5,6 @@ import { useEffect, useState } from 'react' import { useParams } from 'common' import { useEdgeFunctionServiceStatusQuery } from 'data/service-status/edge-functions-status-query' -import { usePostgresServiceStatusQuery } from 'data/service-status/postgres-service-status-query' import { ProjectServiceStatus, useProjectServiceStatusQuery, @@ -112,24 +111,12 @@ const ServiceStatus = () => { refetchInterval: (data) => (!data?.healthy ? 5000 : false), } ) - const { - isLoading: isLoadingPostgres, - isSuccess: isSuccessPostgres, - refetch: refetchPostgresServiceStatus, - } = usePostgresServiceStatusQuery( - { - projectRef: ref, - connectionString: project?.connectionString, - }, - { - refetchInterval: (data) => (data === null ? 5000 : false), - } - ) const authStatus = status?.find((service) => service.name === 'auth') const restStatus = status?.find((service) => service.name === 'rest') const realtimeStatus = status?.find((service) => service.name === 'realtime') const storageStatus = status?.find((service) => service.name === 'storage') + const dbStatus = status?.find((service) => service.name === 'db') // [Joshen] Need individual troubleshooting docs for each service eventually for users to self serve const services: { @@ -145,8 +132,9 @@ const ServiceStatus = () => { name: 'Database', error: undefined, docsUrl: undefined, - isLoading: isLoadingPostgres, - isSuccess: isSuccessPostgres, + isLoading: isLoading, + isSuccess: dbStatus?.healthy, + status: dbStatus?.status, logsUrl: '/logs/postgres-logs', }, { @@ -230,7 +218,6 @@ const ServiceStatus = () => { timer = setTimeout(() => { refetchServiceStatus() - refetchPostgresServiceStatus() refetchEdgeFunctionServiceStatus() }, remainingTimeTillNextCheck * 1000) } diff --git a/apps/studio/data/service-status/postgres-service-status-query.ts b/apps/studio/data/service-status/postgres-service-status-query.ts deleted file mode 100644 index b2343660a6..0000000000 --- a/apps/studio/data/service-status/postgres-service-status-query.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { useQuery, UseQueryOptions } from '@tanstack/react-query' - -import { handleError, post } from 'data/fetchers' -import type { ResponseError } from 'types' -import { serviceStatusKeys } from './keys' - -export type PostgresServiceStatusVariables = { - projectRef?: string - connectionString?: string -} - -export async function getPostgresServiceStatus( - { projectRef, connectionString }: PostgresServiceStatusVariables, - signal?: AbortSignal -) { - if (!projectRef) throw new Error('projectRef is required') - if (!connectionString) throw new Error('connectionString is required') - - let headers = new Headers() - headers.set('x-connection-encrypted', connectionString) - - const { error } = await post('/platform/pg-meta/{ref}/query', { - params: { - header: { 'x-connection-encrypted': connectionString! }, - path: { ref: projectRef }, - // @ts-expect-error Intentional key for easier reference of query in the network tab - query: { key: 'service_status' }, - }, - body: { query: 'select 1' }, - headers, - signal, - }) - - if (error) handleError(error) - return error === undefined -} - -export type PostgresServiceStatusData = Awaited> -export type PostgresServiceStatusError = ResponseError - -export const usePostgresServiceStatusQuery = ( - { projectRef, connectionString }: PostgresServiceStatusVariables, - { - enabled = true, - ...options - }: UseQueryOptions = {} -) => - useQuery( - serviceStatusKeys.postgres(projectRef), - ({ signal }) => getPostgresServiceStatus({ projectRef, connectionString }, signal), - { - enabled: - enabled && typeof projectRef !== 'undefined' && typeof connectionString !== 'undefined', - staleTime: 0, - ...options, - } - ) diff --git a/apps/studio/data/service-status/service-status-query.ts b/apps/studio/data/service-status/service-status-query.ts index 4b47577a93..78eb015b8f 100644 --- a/apps/studio/data/service-status/service-status-query.ts +++ b/apps/studio/data/service-status/service-status-query.ts @@ -18,7 +18,7 @@ export async function getProjectServiceStatus( params: { path: { ref: projectRef }, query: { - services: ['auth', 'realtime', 'rest', 'storage'], + services: ['auth', 'realtime', 'rest', 'storage', 'db'], }, }, signal,