Home / Function/ calculateThroughputPrice() — supabase Function Reference

calculateThroughputPrice() — supabase Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  82fbd301_9a53_6173_3379_5ab985e7d49c["calculateThroughputPrice()"]
  123688a6_401c_ee61_a6d4_f7478222cf84["DiskManagementReviewAndSubmitDialog()"]
  123688a6_401c_ee61_a6d4_f7478222cf84 -->|calls| 82fbd301_9a53_6173_3379_5ab985e7d49c
  6c764bad_2ec9_d037_b951_fe7119643ca5["ThroughputField()"]
  6c764bad_2ec9_d037_b951_fe7119643ca5 -->|calls| 82fbd301_9a53_6173_3379_5ab985e7d49c
  style 82fbd301_9a53_6173_3379_5ab985e7d49c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts lines 131–160

export const calculateThroughputPrice = ({
  storageType,
  newThroughput,
  oldThroughput,
  numReplicas = 0,
}: {
  storageType: DiskType
  newThroughput: number
  oldThroughput: number
  numReplicas?: number
}) => {
  if (storageType === DiskType.GP3 && newThroughput) {
    const oldChargeableThroughput = Math.max(
      0,
      oldThroughput - DISK_LIMITS[DiskType.GP3].includedThroughput
    )
    const newChargeableThroughput = Math.max(
      0,
      newThroughput - DISK_LIMITS[DiskType.GP3].includedThroughput
    )
    const oldPrice = oldChargeableThroughput * DISK_PRICING[DiskType.GP3].throughput
    const newPrice = newChargeableThroughput * DISK_PRICING[DiskType.GP3].throughput

    return {
      oldPrice: (oldPrice * (1 + numReplicas)).toFixed(2),
      newPrice: (newPrice * (1 + numReplicas)).toFixed(2),
    }
  }
  return { oldPrice: '0.00', newPrice: '0.00' }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free