Home / Function/ calculateDiskSizePrice() — supabase Function Reference

calculateDiskSizePrice() — supabase Function Reference

Architecture documentation for the calculateDiskSizePrice() function in DiskManagement.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  d41389fd_6aaa_c3c5_2a46_1dc46dac56c5["calculateDiskSizePrice()"]
  123688a6_401c_ee61_a6d4_f7478222cf84["DiskManagementReviewAndSubmitDialog()"]
  123688a6_401c_ee61_a6d4_f7478222cf84 -->|calls| d41389fd_6aaa_c3c5_2a46_1dc46dac56c5
  d8a70ea0_e63e_e795_0c5c_08cebbf2f4c1["DiskSizeField()"]
  d8a70ea0_e63e_e795_0c5c_08cebbf2f4c1 -->|calls| d41389fd_6aaa_c3c5_2a46_1dc46dac56c5
  style d41389fd_6aaa_c3c5_2a46_1dc46dac56c5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts lines 18–46

export const calculateDiskSizePrice = ({
  planId,
  oldSize,
  oldStorageType,
  newSize,
  newStorageType,
  numReplicas = 0,
}: {
  planId: string
  oldSize: number
  oldStorageType: DiskType
  newSize: number
  newStorageType: DiskType
  numReplicas?: number
}) => {
  const oldPricePerGB = DISK_PRICING[oldStorageType]?.storage ?? 0
  const newPricePerGB = DISK_PRICING[newStorageType]?.storage ?? 0
  const { includedDiskGB } = PLAN_DETAILS?.[planId as keyof typeof PLAN_DETAILS]

  const oldPrice = Math.max(oldSize - includedDiskGB[oldStorageType], 0) * oldPricePerGB
  const oldPriceReplica = oldSize * 1.25 * oldPricePerGB
  const newPrice = Math.max(newSize - includedDiskGB[newStorageType], 0) * newPricePerGB
  const newPriceReplica = newSize * 1.25 * newPricePerGB

  return {
    oldPrice: (oldPrice + numReplicas * oldPriceReplica).toFixed(2),
    newPrice: (newPrice + numReplicas * newPriceReplica).toFixed(2),
  }
}

Subdomains

Frequently Asked Questions

What does calculateDiskSizePrice() do?
calculateDiskSizePrice() is a function in the supabase codebase.
What calls calculateDiskSizePrice()?
calculateDiskSizePrice() is called by 2 function(s): DiskManagementReviewAndSubmitDialog, DiskSizeField.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free