pierrejeambrun commented on code in PR #55927:
URL: https://github.com/apache/airflow/pull/55927#discussion_r2435556188
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -346,31 +333,45 @@ def get_grid_ti_summaries(
TaskInstance.dag_version_id,
TaskInstance.start_date,
TaskInstance.end_date,
+ TaskInstance.duration,
)
.where(TaskInstance.dag_id == dag_id)
- .where(
- TaskInstance.run_id == run_id,
- )
+ .where(TaskInstance.run_id == run_id)
),
filters=[],
order_by=SortParam(allowed_attrs=["task_id", "run_id"],
model=TaskInstance).set_value(["task_id"]),
limit=None,
return_total_entries=False,
)
- task_instances = list(session.execute(tis_of_dag_runs))
+
+ task_instances = session.scalars(tis_of_dag_runs).all()
if not task_instances:
raise HTTPException(
status.HTTP_404_NOT_FOUND, f"No task instances for dag_id={dag_id}
run_id={run_id}"
)
- ti_details = collections.defaultdict(list)
+
+ # Build TI details per task_id, adding only the requested duration field.
Review Comment:
```suggestion
```
##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -84,10 +83,25 @@ const Instance = ({ dagId, instance, isGroup, isMapped,
onClick, runId, search,
[dagId, isGroup, isMapped, location.pathname, runId, taskId],
);
+ const start: string | undefined = instance.min_start_date ?? undefined;
+ const end: string | undefined = instance.max_end_date ?? undefined;
Review Comment:
```suggestion
const start: string | undefined = instance?.min_start_date
const end: string | undefined = instance?.max_end_date
```
##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -84,10 +83,25 @@ const Instance = ({ dagId, instance, isGroup, isMapped,
onClick, runId, search,
[dagId, isGroup, isMapped, location.pathname, runId, taskId],
);
+ const start: string | undefined = instance.min_start_date ?? undefined;
+ const end: string | undefined = instance.max_end_date ?? undefined;
+ const hasStart = start !== undefined;
+ const hasEnd = end !== undefined;
+
+ const serverDurationUnknown = (instance as unknown as { duration?: unknown
}).duration;
+ const serverDurationSeconds = typeof serverDurationUnknown === "number" ?
serverDurationUnknown : undefined;
+
+ const durationText =
+ serverDurationSeconds === undefined ? getDuration(start, end) :
renderDuration(serverDurationSeconds);
+
+ const isSelected =
+ ((selectedTaskId ?? undefined) !== undefined && selectedTaskId === taskId)
||
+ ((selectedGroupId ?? undefined) !== undefined && selectedGroupId ===
taskId);
Review Comment:
`(selectedTaskId ?? undefined)` that's not necessary I believe.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]