(ws: Workspace | undefined)
| 196 | * @returns the latest datetime at which the workspace can be automatically shut down. |
| 197 | */ |
| 198 | export function getMaxDeadline(ws: Workspace | undefined): dayjs.Dayjs { |
| 199 | // note: we count runtime from updated_at as started_at counts from the start of |
| 200 | // the workspace build process, which can take a while. |
| 201 | if (ws === undefined) { |
| 202 | throw Error("Cannot calculate max deadline because workspace is undefined"); |
| 203 | } |
| 204 | const startedAt = dayjs(ws.latest_build.updated_at); |
| 205 | return startedAt.add(deadlineExtensionMax); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Depends on the current time and a global constant. |
no test coverage detected