Files
supabase/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.utils.ts
Saxon Fletcher 3f6cd1f188 error rates in functions list (#44006)
<img width="1835" height="886" alt="image"
src="https://github.com/user-attachments/assets/c4ab5be6-cddc-49b3-8d09-169acb706a20"
/>

Adds total request and error rate columns to edge functions table behind
a feature flag

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: SaxonF <1072756+SaxonF@users.noreply.github.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-25 17:23:46 +08:00

21 lines
516 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Formats a numeric error rate (0100) into a display string.
*
* Examples:
* 0 → "0%"
* 0.05 → "<0.1%"
* 0.1 → "0.1%"
* 1.567 → "1.6%"
* 100 → "100%"
*/
export function formatErrorRate(value: number): string {
if (value === 0) return '0%'
if (value >= 100) return '100%'
if (value < 0.1) return '<0.1%'
const rounded = Number(value.toFixed(1))
const clamped = Math.min(rounded, 100)
if (clamped >= 100) return '100%'
return `${clamped.toFixed(1)}%`
}