The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Have charts dynamic to selected project ref
Joshen Lim00c6952fb97b
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsxindex 401b72c5440..b5c7b444af3 100644--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx@@ -10,10 +10,13 @@ import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'import { generateUsageData } from './Usage.utils'-const Activity = () => {- const { ref } = useParams()- const { data: usage } = useProjectUsageQuery({ projectRef: ref })- const { data: subscription } = useProjectSubscriptionQuery({ projectRef: ref })+export interface ActivityProps {+ projectRef: string+}++const Activity = ({ projectRef }: ActivityProps) => {+ const { data: usage } = useProjectUsageQuery({ projectRef })+ const { data: subscription } = useProjectSubscriptionQuery({ projectRef })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()@@ -22,7 +25,7 @@ const Activity = () => {const { monthly_active_users } = usage ?? {}const mauExcess = (monthly_active_users?.usage ?? 0) - (monthly_active_users?.limit ?? 0)const { data: mauData, isLoading: isLoadingMauData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: MAU_KEY,interval: '1d',startDate,@@ -35,7 +38,7 @@ const Activity = () => {(storage_image_render_count?.usage ?? 0) - (storage_image_render_count?.limit ?? 0)const { data: assetTransformationsData, isLoading: isLoadingAssetTransformationsData } =useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: ASSET_TRANSFORMATIONS_KEY,interval: '1d',startDate,@@ -47,7 +50,7 @@ const Activity = () => {const funcInvocationsExcess = (func_invocations?.usage ?? 0) - (func_invocations?.limit ?? 0)const { data: funcInvocationsData, isLoading: isLoadingFuncInvocationsData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: FUNC_INVOCATIONS_KEY,interval: '1d',startDate,diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsxindex 7bb725e9347..edbfe152ad8 100644--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx@@ -9,12 +9,14 @@ import { Button } from 'ui'import BarChart from './BarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'-import { Y_DOMAIN_CEILING_MULTIPLIER } from './Usage.constants'-const Bandwidth = () => {- const { ref } = useParams()- const { data: usage } = useProjectUsageQuery({ projectRef: ref })- const { data: subscription } = useProjectSubscriptionQuery({ projectRef: ref })+export interface BandwidthProps {+ projectRef: string+}++const Bandwidth = ({ projectRef }: BandwidthProps) => {+ const { data: usage } = useProjectUsageQuery({ projectRef })+ const { data: subscription } = useProjectSubscriptionQuery({ projectRef })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()@@ -24,7 +26,7 @@ const Bandwidth = () => {const { db_egress } = usage ?? {}const dbEgressExcess = (db_egress?.usage ?? 0) - (db_egress?.limit ?? 0)const { data: dbEgressData, isLoading: isLoadingDbEgressData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: DB_EGRESS_KEY,interval: '1d',startDate,@@ -35,7 +37,7 @@ const Bandwidth = () => {const { storage_egress } = usage ?? {}const storageEgressExcess = (storage_egress?.usage ?? 0) - (storage_egress?.limit ?? 0)const { data: storageEgressData, isLoading: isLoadingStorageEgressData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: STORAGE_EGRESS_KEY,interval: '1d',startDate,diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsxindex 1cf17141e17..4b80ab93871 100644--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx@@ -1,4 +1,3 @@-import { useParams } from 'common'import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'@@ -6,16 +5,19 @@ import BarChart from './BarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'-const Infrastructure = () => {- const { ref } = useParams()- const { data: subscription } = useProjectSubscriptionQuery({ projectRef: ref })+export interface InfrastructureProps {+ projectRef: string+}++const Infrastructure = ({ projectRef }: InfrastructureProps) => {+ const { data: subscription } = useProjectSubscriptionQuery({ projectRef })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 CPU_USAGE_KEY = 'cpu_usage'const { data: cpuUsageData, isLoading: isLoadingCpuUsageData } = useInfraMonitoringQuery({- projectRef: ref,+ projectRef,attribute: CPU_USAGE_KEY,interval: '1d',startDate,@@ -24,7 +26,7 @@ const Infrastructure = () => {const MEMORY_USAGE_KEY = 'ram_usage'const { data: memoryUsageData, isLoading: isLoadingMemoryUsageData } = useInfraMonitoringQuery({- projectRef: ref,+ projectRef,attribute: MEMORY_USAGE_KEY,interval: '1d',startDate,@@ -33,7 +35,7 @@ const Infrastructure = () => {const DISK_IO_BUDGET_KEY = 'disk_io_budget'const { data: ioBudgetData, isLoading: isLoadingIoBudgetData } = useInfraMonitoringQuery({- projectRef: ref,+ projectRef,attribute: DISK_IO_BUDGET_KEY,interval: '1d',startDate,diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsxindex 48751ea6fcc..4625e223aa5 100644--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx@@ -10,10 +10,13 @@ import BarChart from './BarChart'import SectionContent from './SectionContent'import SectionHeader from './SectionHeader'-const SizeAndCounts = () => {- const { ref } = useParams()- const { data: usage } = useProjectUsageQuery({ projectRef: ref })- const { data: subscription } = useProjectSubscriptionQuery({ projectRef: ref })+export interface SizeAndCountsProps {+ projectRef: string+}++const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {+ const { data: usage } = useProjectUsageQuery({ projectRef })+ const { data: subscription } = useProjectSubscriptionQuery({ projectRef })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()@@ -22,7 +25,7 @@ const SizeAndCounts = () => {const { db_size } = usage ?? {}const dbSizeExcess = (db_size?.usage ?? 0) - (db_size?.limit ?? 0)const { data: dbSizeData, isLoading: isLoadingDbSizeData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: TOTAL_DB_SIZE_KEY,interval: '1d',startDate,@@ -33,7 +36,7 @@ const SizeAndCounts = () => {const { storage_size } = usage ?? {}const storageSizeExcess = (storage_size?.usage ?? 0) - (storage_size?.limit ?? 0)const { data: storageSizeData, isLoading: isLoadingStorageSizeData } = useDailyStatsQuery({- projectRef: ref,+ projectRef,attribute: TOTAL_STORAGE_SIZE_KEY,interval: '1d',startDate,diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsxindex e5f85728f99..9d0ae2cf3e7 100644--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx@@ -54,6 +54,7 @@ const Usage = () => {<div className="flex items-center justify-between"><div className="flex items-center space-x-4"><Listbox+ disabledsize="small"id="billingCycle"name="billingCycle"@@ -139,16 +140,16 @@ const Usage = () => {</div><div ref={infrastructureRef}>- <Infrastructure />+ <Infrastructure projectRef={selectedProjectRef} /></div><div ref={bandwidthRef}>- <Bandwidth />+ <Bandwidth projectRef={selectedProjectRef} /></div><div ref={sizeAndCountsRef}>- <SizeAndCounts />+ <SizeAndCounts projectRef={selectedProjectRef} /></div><div ref={activityRef}>- <Activity />+ <Activity projectRef={selectedProjectRef} /></div></>)