( lagInfo: LagInfo | null | undefined, )
| 35 | * e.g. `20h` or `12m` or `42s` |
| 36 | */ |
| 37 | export 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 | * |
no test coverage detected