Home / Function/ calculateComputeSizePrice() — supabase Function Reference

calculateComputeSizePrice() — supabase Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e956c7de_38d1_c092_0776_7cdf6ab921bb["calculateComputeSizePrice()"]
  123688a6_401c_ee61_a6d4_f7478222cf84["DiskManagementReviewAndSubmitDialog()"]
  123688a6_401c_ee61_a6d4_f7478222cf84 -->|calls| e956c7de_38d1_c092_0776_7cdf6ab921bb
  89db9652_2ad7_69fe_cba1_2cfbc054b2c2["ComputeSizeField()"]
  89db9652_2ad7_69fe_cba1_2cfbc054b2c2 -->|calls| e956c7de_38d1_c092_0776_7cdf6ab921bb
  style e956c7de_38d1_c092_0776_7cdf6ab921bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/DiskManagement/DiskManagement.utils.ts lines 48–82

export const calculateComputeSizePrice = ({
  availableOptions,
  oldComputeSize,
  newComputeSize,
  plan,
}: {
  availableOptions: {
    identifier: string
    price: number
  }[]
  oldComputeSize: string
  newComputeSize: string
  plan: PlanId
}) => {
  let _oldComputeSize = oldComputeSize

  if (plan !== 'free' && oldComputeSize === 'ci_nano') {
    /**
     * override the old compute size to micro if the plan is not free
     * this is to handle the case in which nano compute is a paid entity
     */
    _oldComputeSize = 'ci_micro'
  }

  const oldPrice = availableOptions?.find((x) => x.identifier === _oldComputeSize)?.price ?? 0
  const newPrice = availableOptions?.find((x) => x.identifier === newComputeSize)?.price ?? 0

  const oldPriceMonthly = oldPrice * 720
  const newPriceMonthly = newPrice * 720

  return {
    oldPrice: oldPriceMonthly.toFixed(2),
    newPrice: newPriceMonthly.toFixed(2),
  }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free