mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 01:40:13 -04:00
3f6cd1f188
<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>
21 lines
516 B
TypeScript
21 lines
516 B
TypeScript
/**
|
||
* Formats a numeric error rate (0–100) 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)}%`
|
||
}
|