Update duration to display in seconds instead of milliseconds

pull/13304/head
Palak Bhojani 2019-04-10 14:27:29 -07:00
parent db2b9e278e
commit a5369fbab4
1 changed files with 14 additions and 1 deletions

View File

@ -469,7 +469,7 @@ export const getRuns = (taskID: string) => async (dispatch): Promise<void> => {
return {
...run,
duration: `${finished.getTime() - started.getTime()} seconds`,
duration: `${runDuration(finished, started)}`,
}
})
@ -535,3 +535,16 @@ export const createTaskFromTemplate = (template: ITaskTemplate) => async (
dispatch(notify(importTaskFailed(error)))
}
}
export const runDuration = (finishedAt: Date, startedAt: Date): string => {
let timeTag = 'seconds'
let diff = (finishedAt.getTime() - startedAt.getTime()) / 1000
if (diff > 60) {
diff = Math.round(diff / 60)
timeTag = 'minutes'
}
return diff + ' ' + timeTag
}