formatUsage() — supabase Function Reference
Architecture documentation for the formatUsage() function in helpers.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD 33d44cde_fee6_d849_e1fe_792e48dd1fdb["formatUsage()"] 92c2398a_cf4a_5148_b198_86c7e7bb2151["BillingMetric()"] 92c2398a_cf4a_5148_b198_86c7e7bb2151 -->|calls| 33d44cde_fee6_d849_e1fe_792e48dd1fdb 0f2db04c_9101_bc21_2789_4675e57f7c68["ComputeMetric()"] 0f2db04c_9101_bc21_2789_4675e57f7c68 -->|calls| 33d44cde_fee6_d849_e1fe_792e48dd1fdb 2c85c7d8_937d_2785_9b6c_5080fa88a0c8["UpcomingInvoice()"] 2c85c7d8_937d_2785_9b6c_5080fa88a0c8 -->|calls| 33d44cde_fee6_d849_e1fe_792e48dd1fdb style 33d44cde_fee6_d849_e1fe_792e48dd1fdb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Organization/BillingSettings/helpers.ts lines 21–48
export const formatUsage = (
pricingMetric: PricingMetric,
allocation: { usage: number; hours?: number }
) => {
if (pricingMetricBytes.includes(pricingMetric)) {
const formattedUsage = +(allocation.usage / 1e9).toFixed(2).toLocaleString()
// To avoid very low usage displaying as "0", we will show "<0.01" instead
if (allocation.usage > 0 && formattedUsage === 0) {
return '<0.01'
} else {
return formattedUsage
}
}
if (allocation.hours && !pricingMetricNotHrs.includes(pricingMetric)) {
return (
allocation.usage.toLocaleString() +
' (' +
Math.round(allocation.usage / allocation.hours).toLocaleString() +
'x' +
allocation.hours.toLocaleString() +
' hours)'
)
} else {
return allocation.usage.toLocaleString()
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does formatUsage() do?
formatUsage() is a function in the supabase codebase.
What calls formatUsage()?
formatUsage() is called by 3 function(s): BillingMetric, ComputeMetric, UpcomingInvoice.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free