import Link from 'next/link' import { useMemo } from 'react' import { Alert, AlertDescription, AlertTitle, Button, CriticalIcon } from 'ui' import { InfoTooltip } from 'ui-patterns/info-tooltip' import { SectionContent } from '../SectionContent' import { CategoryAttribute } from '../Usage.constants' import Panel from '@/components/ui/Panel' import { PricingMetric } from '@/data/analytics/org-daily-stats-query' import type { OrgSubscription } from '@/data/subscriptions/types' import { OrgUsageResponse } from '@/data/usage/org-usage-query' import { formatBytes } from '@/lib/helpers' export interface DatabaseSizeUsageProps { slug: string projectRef?: string | null attribute: CategoryAttribute subscription?: OrgSubscription usage?: OrgUsageResponse currentBillingCycleSelected: boolean } const DatabaseSizeUsage = ({ attribute, subscription, usage, currentBillingCycleSelected, }: DatabaseSizeUsageProps) => { const databaseSizeUsage = useMemo( () => usage?.usages.find((it) => it.metric === PricingMetric.DATABASE_SIZE), [usage] ) const hasProjectsExceedingDatabaseSize = useMemo(() => { return databaseSizeUsage?.project_allocations.some((it) => it.usage > 0.5 * 1e9) }, [databaseSizeUsage]) return (
{attribute.name} usage
Included in {subscription?.plan?.name} Plan
0.5 GB per project
Max database size
{databaseSizeUsage?.usage ? formatBytes(databaseSizeUsage?.usage_original) : '-'}
Current database size per project
No active projects
You don't have any active projects in this organization.
{formatBytes(project.usage)} GB database size as reported by Postgres.
Data not available
Switch to current billing cycle to see current database size per project.