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
This commit is contained in:
parent
09b4b8a5b3
commit
3f08a93e9e
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue