mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: handle NaN in build time estimate (#5679)
This commit is contained in:
@@ -67,3 +67,9 @@ StartingHighVariaton.args = {
|
||||
...Starting.args,
|
||||
transitionStats: { P50: 10000, P95: 20000 },
|
||||
}
|
||||
|
||||
export const StartingZeroEstimate = Template.bind({})
|
||||
StartingZeroEstimate.args = {
|
||||
...Starting.args,
|
||||
transitionStats: { P50: 0, P95: 0 },
|
||||
}
|
||||
|
||||
@@ -34,11 +34,13 @@ const estimateFinish = (
|
||||
p95: number,
|
||||
): [number | undefined, string] => {
|
||||
const sinceStart = dayjs().diff(startedAt)
|
||||
const secondsLeft = (est: number) =>
|
||||
Math.max(
|
||||
const secondsLeft = (est: number) => {
|
||||
const max = Math.max(
|
||||
Math.ceil(dayjs.duration((1 - sinceStart / est) * est).asSeconds()),
|
||||
0,
|
||||
)
|
||||
return isNaN(max) ? 0 : max
|
||||
}
|
||||
|
||||
const lowGuess = secondsLeft(p50)
|
||||
const highGuess = secondsLeft(p95)
|
||||
|
||||
Reference in New Issue
Block a user