Skip to content

Commit

Permalink
fix: duration is not always calculated for task executions
Browse files Browse the repository at this point in the history
Signed-off-by: csirius <davidtruong.dev@gmail.com>
  • Loading branch information
csirius committed Aug 18, 2021
1 parent 950950d commit b387ef8
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,42 @@ import * as React from 'react';
export const TaskExecutionDetails: React.FC<{
taskExecution: TaskExecution;
}> = ({ taskExecution }) => {
const labelWidthGridUnits = taskExecution.closure.startedAt ? 7 : 10;
const detailItems = React.useMemo(() => {
if (taskExecution.closure.startedAt) {
return [
{
name: 'started',
content: dateWithFromNow(
timestampToDate(taskExecution.closure.startedAt)
)
},
{
name: 'run time',
content: taskExecution.closure.duration
? protobufDurationToHMS(taskExecution.closure.duration)
: unknownValueString
}
];
} else {
return [
{
name: 'last updated',
content: taskExecution.closure.updatedAt
? dateWithFromNow(
timestampToDate(taskExecution.closure.updatedAt)
)
: unknownValueString
}
];
}
}, [taskExecution]);

return (
<section>
<DetailsGroup
labelWidthGridUnits={7}
items={[
{
name: 'started',
content: taskExecution.closure.startedAt
? dateWithFromNow(
timestampToDate(
taskExecution.closure.startedAt
)
)
: unknownValueString
},
{
name: 'run time',
content: taskExecution.closure.duration
? protobufDurationToHMS(
taskExecution.closure.duration
)
: unknownValueString
}
]}
labelWidthGridUnits={labelWidthGridUnits}
items={detailItems}
/>
</section>
);
Expand Down

0 comments on commit b387ef8

Please sign in to comment.