Merge pull request #13767 from influxdata/fix-tasks-runs-nan

Update task run to not display NaN seconds
pull/13736/head
Palakp41 2019-05-03 11:15:54 -07:00 committed by GitHub
commit 6b2562c468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -490,9 +490,15 @@ export const taskImportSuccess = (): Notification => ({
})
export const taskRunSuccess = (): Notification => ({
...defaultErrorNotification,
duration: FIVE_SECONDS,
message: 'Task scheduled successfully',
})
export const taskRunFailed = (error: string): Notification => ({
...defaultSuccessNotification,
duration: FIVE_SECONDS,
message: 'Task ran successfully',
message: `Failed to run task: ${error}`,
})
export const taskGetFailed = (error: string): Notification => ({

View File

@ -501,6 +501,8 @@ export const runTask = (taskID: string) => async dispatch => {
await client.tasks.startRunByTaskID(taskID)
dispatch(notify(taskRunSuccess()))
} catch (error) {
const message = getErrorMessage(error)
dispatch(notify(copy.taskRunFailed(message)))
console.error(error)
}
}
@ -558,6 +560,9 @@ export const createTaskFromTemplate = (template: ITaskTemplate) => async (
export const runDuration = (finishedAt: Date, startedAt: Date): string => {
let timeTag = 'seconds'
if (isNaN(finishedAt.getTime()) || isNaN(startedAt.getTime())) {
return ''
}
let diff = (finishedAt.getTime() - startedAt.getTime()) / 1000
if (diff > 60) {