The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Highlight infra tab if io budget exceeds or approaching
Joshen Lime3b0acd1f51c
diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsxindex 24ca3600f6d..87cbedee0ec 100644--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx@@ -59,7 +59,7 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {const currentDayIoBudget = Number(ioBudgetData?.data.find((x) => x.periodStartFormatted === dayjs().format('DD MMM'))?.['disk_io_budget'- ] ?? 0+ ] ?? 100)const chartMeta: any = {@@ -100,7 +100,6 @@ const Infrastructure = ({ projectRef }: InfrastructureProps) => {<SectionContent key={attribute.key} section={attribute} lastKnownValue={lastKnownValue}>{attribute.key === 'disk_io_budget' && (<>- {/* The condition should be that if the disk io budget for TODAY has crossed some threshold */}{currentDayIoBudget <= 0 ? (<Alert withIcon variant="danger" title="IO Budget for today has been used up"><p className="mb-4">diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsxindex c58343844a8..d682a025f3e 100644--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx@@ -12,6 +12,7 @@ import Infrastructure from './Infrastructure'import SizeAndCounts from './SizeAndCounts'import { USAGE_CATEGORIES, USAGE_STATUS } from './Usage.constants'import { getUsageStatus } from './Usage.utils'+import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'const Usage = () => {const { ref } = useParams()@@ -30,6 +31,22 @@ const Usage = () => {projectRef: selectedProjectRef,})+ const { current_period_start, current_period_end } = subscription?.billing ?? {}+ const startDate = new Date((current_period_start ?? 0) * 1000).toISOString()+ const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()+ const { data: ioBudgetData } = useInfraMonitoringQuery({+ projectRef: selectedProjectRef,+ attribute: 'disk_io_budget',+ interval: '1d',+ startDate,+ endDate,+ })+ const currentDayIoBudget = Number(+ ioBudgetData?.data.find((x) => x.periodStartFormatted === dayjs().format('DD MMM'))?.[+ 'disk_io_budget'+ ] ?? 100+ )+const billingCycleStart = dayjs.unix(subscription?.billing?.current_period_start ?? 0).utc()const billingCycleEnd = dayjs.unix(subscription?.billing?.current_period_end ?? 0).utc()@@ -104,7 +121,14 @@ const Usage = () => {<div className="flex items-center space-x-6 !mt-2">{USAGE_CATEGORIES.map((category) => {- const status = getUsageStatus(category.attributes, usage)+ const infraStatus =+ currentDayIoBudget <= 0+ ? USAGE_STATUS.EXCEEDED+ : currentDayIoBudget <= 20+ ? USAGE_STATUS.APPROACHING+ : USAGE_STATUS.NORMAL+ const status =+ category.key === 'infra' ? infraStatus : getUsageStatus(category.attributes, usage)return (<div