Skip to content

Commit

Permalink
Calculate duration in UI (#23259)
Browse files Browse the repository at this point in the history
* Calculate duration in UI

* calculate mapped instance duration too
  • Loading branch information
bbovenzi authored Apr 26, 2022
1 parent 511ea70 commit 9e2531f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions airflow/www/static/js/tree/InstanceTooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Time from './Time';
const InstanceTooltip = ({
group,
instance: {
startDate, endDate, duration, state, runId, mappedStates,
startDate, endDate, state, runId, mappedStates,
},
}) => {
const isGroup = !!group.children;
Expand Down Expand Up @@ -91,7 +91,7 @@ const InstanceTooltip = ({
<Text>
Duration:
{' '}
{formatDuration(duration || getDuration(startDate, endDate))}
{formatDuration(getDuration(startDate, endDate))}
</Text>
</Box>
);
Expand Down
5 changes: 2 additions & 3 deletions airflow/www/static/js/tree/details/content/dagRun/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { MdPlayArrow, MdOutlineAccountTree } from 'react-icons/md';

import { SimpleStatus } from '../../../StatusBox';
import { ClipboardText } from '../../../Clipboard';
import { formatDuration } from '../../../../datetime_utils';
import { formatDuration, getDuration } from '../../../../datetime_utils';
import Time from '../../../Time';
import MarkFailedRun from './MarkFailedRun';
import MarkSuccessRun from './MarkSuccessRun';
Expand All @@ -50,7 +50,6 @@ const DagRun = ({ runId }) => {
executionDate,
state,
runType,
duration,
lastSchedulingDecision,
dataIntervalStart,
dataIntervalEnd,
Expand Down Expand Up @@ -103,7 +102,7 @@ const DagRun = ({ runId }) => {
<Text>
Duration:
{' '}
{formatDuration(duration)}
{formatDuration(getDuration(startDate, endDate))}
</Text>
{lastSchedulingDecision && (
<Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const Details = ({ instance, group, operator }) => {
const {
taskId,
runId,
duration,
startDate,
endDate,
state,
Expand Down Expand Up @@ -134,7 +133,7 @@ const Details = ({ instance, group, operator }) => {
{isOverall}
Duration:
{' '}
{formatDuration(duration || getDuration(startDate, endDate))}
{formatDuration(getDuration(startDate, endDate))}
</Text>
{startDate && (
<Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from 'react-icons/md';

import { getMetaValue } from '../../../../utils';
import { formatDateTime, formatDuration } from '../../../../datetime_utils';
import { formatDateTime, formatDuration, getDuration } from '../../../../datetime_utils';
import { useMappedInstances } from '../../../api';
import { SimpleStatus } from '../../../StatusBox';
import Table from '../../../Table';
Expand Down Expand Up @@ -83,7 +83,7 @@ const MappedInstances = ({
{mi.state || 'no status'}
</Flex>
),
duration: mi.duration && formatDuration(mi.duration),
duration: mi.duration && formatDuration(getDuration(mi.startDate, mi.endDate)),
startDate: mi.startDate && formatDateTime(mi.startDate),
endDate: mi.endDate && formatDateTime(mi.endDate),
links: (
Expand Down
1 change: 0 additions & 1 deletion airflow/www/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def encode_ti(
'run_id': task_instance.run_id,
'map_index': task_instance.map_index,
'state': task_instance.state,
'duration': task_instance.duration,
'start_date': datetime_to_string(task_instance.start_date),
'end_date': datetime_to_string(task_instance.end_date),
'try_number': try_count,
Expand Down

0 comments on commit 9e2531f

Please sign in to comment.