This is an automated email from the ASF dual-hosted git repository.
bbovenzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0376e9324a Fix gantt chart queued duration when queued_dttm is greater
than start_date for deferred tasks. (#35984)
0376e9324a is described below
commit 0376e9324af7dfdafd246e31827780e855078d68
Author: Karthikeyan Singaravelan <[email protected]>
AuthorDate: Tue Dec 5 19:33:55 2023 +0530
Fix gantt chart queued duration when queued_dttm is greater than start_date
for deferred tasks. (#35984)
* Fix gantt chart queued duration when queued_dttm is greater than
start_date for deferred tasks.
* Merge hasQueuedDttm and validQueuedDttm.
---
.../static/js/dag/details/gantt/GanttTooltip.tsx | 8 ++++---
airflow/www/static/js/dag/details/gantt/Row.tsx | 25 +++++++++++++---------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx
b/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx
index 2f50120925..465eaa930e 100644
--- a/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx
+++ b/airflow/www/static/js/dag/details/gantt/GanttTooltip.tsx
@@ -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>
diff --git a/airflow/www/static/js/dag/details/gantt/Row.tsx
b/airflow/www/static/js/dag/details/gantt/Row.tsx
index bf1ce7ac60..1526e1713f 100644
--- a/airflow/www/static/js/dag/details/gantt/Row.tsx
+++ b/airflow/www/static/js/dag/details/gantt/Row.tsx
@@ -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;
@@ -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 (
@@ -106,7 +109,7 @@ const Row = ({
});
}}
>
- {instance.state !== "queued" && hasQueuedDttm && (
+ {instance.state !== "queued" && hasValidQueuedDttm && (
<SimpleStatus
state="queued"
width={`${queuedWidth}px`}
@@ -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>