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

Function formatIntervalShort

console/src/utils/format.ts:139–169  ·  view source on GitHub ↗
(interval: IPostgresInterval)

Source from the content-addressed store, hash-verified

137}
138
139export function formatIntervalShort(interval: IPostgresInterval) {
140 if (interval.years) {
141 const years = roundIntervalValue(interval.years, interval.months, 6);
142 return `${years} ${pluralize(years, "year", "years")}`;
143 }
144 if (interval.months) {
145 const months = roundIntervalValue(interval.months, interval.days, 15);
146 return `${months} ${pluralize(months, "month", "months")}`;
147 }
148 if (interval.days) {
149 const days = roundIntervalValue(interval.days, interval.hours, 12);
150 return `${days} ${pluralize(days, "day", "days")}`;
151 }
152 if (interval.hours) {
153 const hours = roundIntervalValue(interval.hours, interval.minutes, 30);
154 return `${hours} ${pluralize(hours, "hour", "hours")}`;
155 }
156 if (interval.minutes) {
157 const minutes = roundIntervalValue(interval.minutes, interval.seconds, 30);
158 return `${minutes} ${pluralize(minutes, "minute", "minutes")}`;
159 }
160 if (interval.seconds) {
161 const seconds = roundIntervalValue(
162 interval.seconds,
163 interval.milliseconds,
164 500,
165 );
166 return `${seconds} ${pluralize(seconds, "second", "seconds")}`;
167 }
168 return "< 1 second";
169}
170
171export function formatInterval(interval: IPostgresInterval) {
172 const parts: string[] = [];

Callers 7

format.test.tsFile · 0.90
ClusterFreshnessTableFunction · 0.90
SourceOverviewFunction · 0.90
ClusterFreshnessTableFunction · 0.90
FreshnessCellFunction · 0.90
LagBadgeFunction · 0.90
CriticalPathGraphNodeFunction · 0.90

Calls 2

pluralizeFunction · 0.90
roundIntervalValueFunction · 0.85

Tested by

no test coverage detected