fix: add shared number formatting utilities (formatMetric, formatCount, formatPercent)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { useMemo } from 'react';
|
||||
import { useGlobalFilters } from '@cameleer/design-system';
|
||||
import { useExecutionStats } from '../api/queries/executions';
|
||||
import type { Scope } from '../hooks/useScope';
|
||||
import { formatPercent } from '../utils/format-utils';
|
||||
import styles from './TabKpis.module.css';
|
||||
|
||||
interface TabKpisProps {
|
||||
@@ -20,10 +21,6 @@ function formatMs(ms: number): string {
|
||||
return `${Math.round(ms)}ms`;
|
||||
}
|
||||
|
||||
function formatPct(pct: number): string {
|
||||
return `${pct.toFixed(1)}%`;
|
||||
}
|
||||
|
||||
type Trend = 'up' | 'down' | 'flat';
|
||||
|
||||
function trend(current: number, previous: number): Trend {
|
||||
@@ -74,7 +71,7 @@ export function TabKpis({ scope }: TabKpisProps) {
|
||||
|
||||
return [
|
||||
{ label: 'Total', value: formatNum(total), trend: trend(total, prevTotal) },
|
||||
{ label: 'Err%', value: formatPct(errorRate), trend: trend(errorRate, prevErrorRate), upIsBad: true },
|
||||
{ label: 'Err%', value: formatPercent(errorRate), trend: trend(errorRate, prevErrorRate), upIsBad: true },
|
||||
{ label: 'Avg', value: formatMs(avgMs), trend: trend(avgMs, prevAvgMs), upIsBad: true },
|
||||
{ label: 'P99', value: formatMs(p99), trend: trend(p99, prevP99), upIsBad: true },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user