diff options
author | Clark Boylan <clark.boylan@gmail.com> | 2020-01-24 11:54:52 -0800 |
---|---|---|
committer | Clark Boylan <clark.boylan@gmail.com> | 2020-01-27 09:10:28 -0800 |
commit | 3f08a93e9ebb27ccf54173fddf3748bea6b2a69b (patch) | |
tree | 4102e4175df4ad82cc3320706e52908e96af4591 /web/src/containers/status | |
parent | 09b4b8a5b3003b97426a25f059641f0a58d33a8d (diff) | |
download | zuul-3f08a93e9ebb27ccf54173fddf3748bea6b2a69b.tar.gz |
Be more specific with remaining time
With the old code using humaized time it appears to always round down.
This means a job that will run for an hour and 45 minutes is estimated
to complete in an hour. With these sorts of estimates it is my
experience that it is better to over rather than under estimate as
people will get frustrated if it takes twice as long to get their
results as is stated.
To address this we can provide a more specific estimate. We can say "One
hour 45 minutes" instead of "an hour". This gives users a much better
indication of when they can expect results.
Change-Id: I705a636cd2483cdd2b880093747b720f91e6f0e3
Diffstat (limited to 'web/src/containers/status')
-rw-r--r-- | web/src/containers/status/ChangePanel.jsx | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/web/src/containers/status/ChangePanel.jsx b/web/src/containers/status/ChangePanel.jsx index 56515a58c..def966e99 100644 --- a/web/src/containers/status/ChangePanel.jsx +++ b/web/src/containers/status/ChangePanel.jsx @@ -16,7 +16,11 @@ import * as React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { Link } from 'react-router-dom' -import * as moment from 'moment' + +const SECOND = 1000 +const MINUTE = SECOND * 60 +const HOUR = MINUTE * 60 +const DAY = HOUR * 24 class ChangePanel extends React.Component { @@ -193,13 +197,36 @@ class ChangePanel extends React.Component { let className let progressWidth = progressPercent let title = '' + let remaining = remainingTime if (Number.isNaN(progressPercent)) { progressWidth = 100 progressPercent = 0 className = 'progress-bar-striped progress-bar-animated' } - if (remainingTime !== null) { - title = 'estimated time remaining ' + moment.duration(remainingTime, 'milliseconds').humanize() + if (remaining !== null) { + title = 'Estimated time remaining: ' + if (remaining < MINUTE) { + title = title + 'less than a minute' + } else { + let days = 0 + let hours = 0 + let minutes = 0 + + days = Math.trunc(remaining/DAY) + remaining = Math.trunc(remaining%DAY) + hours = Math.trunc(remaining/HOUR) + remaining = Math.trunc(remaining%HOUR) + minutes = Math.trunc(remaining/MINUTE) + if (days > 0) { + title = title + days + ' days ' + } + if (hours > 0) { + title = title + hours + ' hours ' + } + if (minutes > 0) { + title = title + minutes + ' minutes ' + } + } } return ( |