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

Function formatLagInfoSimple

console/src/platform/clusters/format.ts:37–59  ·  view source on GitHub ↗
(
  lagInfo: LagInfo | null | undefined,
)

Source from the content-addressed store, hash-verified

35 * e.g. `20h` or `12m` or `42s`
36 */
37export function formatLagInfoSimple(
38 lagInfo: LagInfo | null | undefined,
39): string {
40 const { lag, hydrated } = lagInfo ?? {};
41 if (hydrated === false) {
42 return "Not hydrated";
43 }
44 if (!lag) return "-";
45 const hours = calculateHoursFromInterval(lag);
46 const minutes = lag?.minutes ?? 0;
47 const seconds = lag?.seconds ?? 0;
48 let formattedString = "";
49 if (hours >= 1) {
50 formattedString = `${hours}h`;
51 } else if (minutes >= 1) {
52 formattedString = `${minutes}m`;
53 } else if (seconds >= 1) {
54 formattedString = `${seconds}s`;
55 } else {
56 formattedString = "Less than 1s";
57 }
58 return formattedString.trim();
59}
60/**
61 * Given a postgres interval, formats the duration as hours minutes and seconds.
62 *

Callers 2

NodeStatusFunction · 0.90
format.test.tsFile · 0.90

Calls 2

trimMethod · 0.45

Tested by

no test coverage detected