tirkarthi commented on code in PR #59814:
URL: https://github.com/apache/airflow/pull/59814#discussion_r2649441598


##########
airflow-core/src/airflow/ui/src/pages/Dag/Tasks/Tasks.tsx:
##########
@@ -57,6 +66,52 @@ export const Tasks = () => {
     dagId,
   });
 
+  // Extract task IDs for batch fetching task instances
+  const taskIds = data?.tasks.map((task) => task.task_id ?? "").filter((id) => 
id) ?? [];
+
+  // Batch fetch task instances for all tasks in one API call
+  const {
+    data: taskInstancesData,
+    error: taskInstancesError,
+    isFetching: isFetchingTaskInstances,
+  } = useQuery({
+    enabled: Boolean(dagId) && taskIds.length > 0,
+    queryFn: () =>
+      TaskInstanceService.getTaskInstancesBatch({
+        dagId: "~",
+        dagRunId: "~",
+        requestBody: {
+          dag_ids: [dagId],
+          order_by: "-run_after",

Review Comment:
   `run_after` is not a valid sorting field on TaskInstance. On loading the 
tasks tab in dag details I can see below error.
   
   ```
   400 Bad Request
   
   Ordering with 'run_after' is disallowed or the attribute does not exist on 
the model
   ```



-- 
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]

Reply via email to