Home / Function/ calculateIOPSPrice() — supabase Function Reference

calculateIOPSPrice() — supabase Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  358afe46_09fa_dd8b_54eb_6c8758ac6b45["calculateIOPSPrice()"]
  123688a6_401c_ee61_a6d4_f7478222cf84["DiskManagementReviewAndSubmitDialog()"]
  123688a6_401c_ee61_a6d4_f7478222cf84 -->|calls| 358afe46_09fa_dd8b_54eb_6c8758ac6b45
  e4f4740e_699b_cee8_77fb_38343fd520bf["IOPSField()"]
  e4f4740e_699b_cee8_77fb_38343fd520bf -->|calls| 358afe46_09fa_dd8b_54eb_6c8758ac6b45
  style 358afe46_09fa_dd8b_54eb_6c8758ac6b45 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts lines 85–126

export const calculateIOPSPrice = ({
  oldStorageType,
  oldProvisionedIOPS,
  newStorageType,
  newProvisionedIOPS,
  numReplicas = 0,
}: {
  oldStorageType: DiskType
  oldProvisionedIOPS: number
  newStorageType: DiskType
  newProvisionedIOPS: number
  numReplicas?: number
}) => {
  if (newStorageType === DiskType.GP3) {
    const oldChargeableIOPS = Math.max(
      0,
      oldProvisionedIOPS - DISK_LIMITS[DiskType.GP3].includedIops
    )
    const newChargeableIOPS = Math.max(
      0,
      newProvisionedIOPS - DISK_LIMITS[DiskType.GP3].includedIops
    )
    const oldPrice = oldChargeableIOPS * (DISK_PRICING[oldStorageType]?.iops ?? 0)
    const newPrice = newChargeableIOPS * (DISK_PRICING[newStorageType]?.iops ?? 0)

    return {
      oldPrice: (oldPrice * (1 + numReplicas)).toFixed(2),
      newPrice: (newPrice * (1 + numReplicas)).toFixed(2),
    }
  } else {
    const oldPrice =
      oldStorageType === 'gp3'
        ? (oldProvisionedIOPS - DISK_LIMITS[oldStorageType].includedIops) *
          DISK_PRICING[oldStorageType].iops
        : oldProvisionedIOPS * (DISK_PRICING[oldStorageType]?.iops ?? 0)
    const newPrice = newProvisionedIOPS * (DISK_PRICING[newStorageType]?.iops ?? 0)
    return {
      oldPrice: (oldPrice * (1 + numReplicas)).toFixed(2),
      newPrice: (newPrice * (1 + numReplicas)).toFixed(2),
    }
  }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free