useGetReplicaCost() — supabase Function Reference
Architecture documentation for the useGetReplicaCost() function in useGetReplicaCost.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD ee997c59_6744_1971_3689_20661b79af94["useGetReplicaCost()"] 0c11bcc5_b8ca_0e1a_337b_47bb1460644c["ReadReplicaPricingDialog()"] 0c11bcc5_b8ca_0e1a_337b_47bb1460644c -->|calls| ee997c59_6744_1971_3689_20661b79af94 416258ae_ed0b_af1a_3a59_08bfdaed6cc3["ReadReplicaForm()"] 416258ae_ed0b_af1a_3a59_08bfdaed6cc3 -->|calls| ee997c59_6744_1971_3689_20661b79af94 style ee997c59_6744_1971_3689_20661b79af94 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicaForm/useGetReplicaCost.ts lines 14–79
export const useGetReplicaCost = () => {
const { ref: projectRef } = useParams()
const { data: addons } = useProjectAddonsQuery({ projectRef })
const { data: diskConfiguration } = useDiskAttributesQuery({ projectRef })
const currentComputeAddon = addons?.selected_addons.find(
(addon) => addon.type === 'compute_instance'
)?.variant.identifier
const computeAddons =
addons?.available_addons.find((addon) => addon.type === 'compute_instance')?.variants ?? []
const selectedComputeMeta = computeAddons.find(
(addon) => addon.identifier === currentComputeAddon
)
const estComputeMonthlyCost = Math.floor((selectedComputeMeta?.price ?? 0) * 730) // 730 hours in a month
// @ts-ignore API types issue
const { size_gb, type, throughput_mbps, iops } = diskConfiguration?.attributes ?? {}
const readReplicaDiskSizes = (size_gb ?? 0) * 1.25
const additionalCostDiskSize =
readReplicaDiskSizes * (DISK_PRICING[type as DiskType]?.storage ?? 0)
const additionalCostIOPS = calculateIOPSPrice({
oldStorageType: type as DiskType,
newStorageType: type as DiskType,
oldProvisionedIOPS: 0,
newProvisionedIOPS: iops ?? 0,
numReplicas: 0,
}).newPrice
const additionalCostThroughput =
type === 'gp3'
? calculateThroughputPrice({
storageType: type as DiskType,
newThroughput: throughput_mbps ?? 0,
oldThroughput: 0,
numReplicas: 0,
}).newPrice
: 0
const totalCost = formatCurrency(
estComputeMonthlyCost +
additionalCostDiskSize +
Number(additionalCostIOPS) +
Number(additionalCostThroughput)
)
return {
totalCost,
compute: {
label: selectedComputeMeta?.name,
cost: formatCurrency(estComputeMonthlyCost),
priceDescription: selectedComputeMeta?.price_description,
},
disk: {
type,
label: `${((size_gb ?? 0) * 1.25).toLocaleString()} GB (${type})`,
cost: formatCurrency(additionalCostDiskSize),
},
iops: {
label: `${iops?.toLocaleString()} IOPS`,
cost: formatCurrency(+additionalCostIOPS),
},
throughput: {
label: `${throughput_mbps?.toLocaleString()} MB/s`,
cost: formatCurrency(+additionalCostThroughput),
},
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does useGetReplicaCost() do?
useGetReplicaCost() is a function in the supabase codebase.
What calls useGetReplicaCost()?
useGetReplicaCost() is called by 2 function(s): ReadReplicaForm, ReadReplicaPricingDialog.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free