MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / formatDurationForAxis

Function formatDurationForAxis

console/src/utils/format.ts:202–216  ·  view source on GitHub ↗
(durationMs: number)

Source from the content-addressed store, hash-verified

200}
201
202export function formatDurationForAxis(durationMs: number): string {
203 // Cap at 24 hours (86,400,000 ms)
204 const cappedMs = Math.min(durationMs, MAX_LAG_MS);
205
206 if (cappedMs < 1000) {
207 return `${Math.round(cappedMs)}ms`;
208 } else if (cappedMs < 60000) {
209 return `${cappedMs / 1000}s`;
210 } else if (cappedMs < 3600000) {
211 return `${Math.round(cappedMs / 60000)}m`;
212 } else {
213 const hours = cappedMs / 3600000;
214 return `${hours.toFixed(1)}h`;
215 }
216}
217
218export const formatPercentage = (percentage: number) =>
219 `${(percentage * 100).toFixed(2)}%`;

Callers 2

FreshnessGraphInnerFunction · 0.90
FreshnessBreakdownStripFunction · 0.90

Calls 1

minMethod · 0.80

Tested by

no test coverage detected