Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gantt chart queued duration when queued_dttm is greater than start_date for deferred tasks. #35984

Merged
merged 2 commits into from Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx
Expand Up @@ -34,9 +34,11 @@ const GanttTooltip = ({ task, instance }: Props) => {

// Calculate durations in ms
const taskDuration = getDuration(instance?.startDate, instance?.endDate);
const queuedDuration = instance?.queuedDttm
? getDuration(instance.queuedDttm, instance?.startDate)
: 0;
const queuedDuration =
instance?.queuedDttm &&
(instance?.startDate ? instance.queuedDttm < instance.startDate : true)
? getDuration(instance.queuedDttm, instance?.startDate)
: 0;
return (
<Box>
<Text>
Expand Down
25 changes: 15 additions & 10 deletions airflow/www/static/js/dag/details/gantt/Row.tsx
Expand Up @@ -52,18 +52,21 @@ const Row = ({

const instance = task.instances.find((ti) => ti.runId === runId);
const isSelected = taskId === instance?.taskId;
const hasQueuedDttm = !!instance?.queuedDttm;
const hasValidQueuedDttm =
!!instance?.queuedDttm &&
(instance?.startDate && instance?.queuedDttm
? instance.queuedDttm < instance.startDate
: true);
const isOpen = openGroupIds.includes(task.id || "");

// Calculate durations in ms
const taskDuration = getDuration(instance?.startDate, instance?.endDate);
const queuedDuration = hasQueuedDttm
const queuedDuration = hasValidQueuedDttm
? getDuration(instance?.queuedDttm, instance?.startDate)
: 0;
const taskStartOffset = getDuration(
ganttStartDate,
instance?.queuedDttm || instance?.startDate
);
const taskStartOffset = hasValidQueuedDttm
? getDuration(ganttStartDate, instance?.queuedDttm || instance?.startDate)
: getDuration(ganttStartDate, instance?.startDate);

// Percent of each duration vs the overall dag run
const taskDurationPercent = taskDuration / runDuration;
Expand All @@ -74,8 +77,8 @@ const Row = ({
// Min width should be 5px
let width = ganttWidth * taskDurationPercent;
if (width < 5) width = 5;
let queuedWidth = hasQueuedDttm ? ganttWidth * queuedDurationPercent : 0;
if (hasQueuedDttm && queuedWidth < 5) queuedWidth = 5;
let queuedWidth = hasValidQueuedDttm ? ganttWidth * queuedDurationPercent : 0;
if (hasValidQueuedDttm && queuedWidth < 5) queuedWidth = 5;
const offsetMargin = taskStartOffsetPercent * ganttWidth;

return (
Expand Down Expand Up @@ -106,7 +109,7 @@ const Row = ({
});
}}
>
{instance.state !== "queued" && hasQueuedDttm && (
{instance.state !== "queued" && hasValidQueuedDttm && (
<SimpleStatus
state="queued"
width={`${queuedWidth}px`}
Expand All @@ -119,7 +122,9 @@ const Row = ({
state={instance.state}
width={`${width}px`}
borderLeftRadius={
instance.state !== "queued" && hasQueuedDttm ? 0 : undefined
instance.state !== "queued" && hasValidQueuedDttm
? 0
: undefined
}
/>
</Flex>
Expand Down