bbovenzi commented on code in PR #35863:
URL: https://github.com/apache/airflow/pull/35863#discussion_r1425964851


##########
airflow/www/static/js/dag/details/taskDuration/index.tsx:
##########
@@ -0,0 +1,244 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global moment */
+
+import React from "react";
+
+import useSelection from "src/dag/useSelection";
+import { useGridData } from "src/api";
+import { getDuration, formatDateTime } from "src/datetime_utils";
+import ReactECharts, { ReactEChartsProps } from "src/components/ReactECharts";
+import type { TaskInstance } from "src/types";
+
+class TaskInstanceDuration {
+  instance: TaskInstance;
+
+  dataIntervalStart: string;
+
+  dataIntervalEnd: string;
+
+  executionDate: string;
+
+  runDuration: moment.Duration;
+
+  runDurationUnit: number = 0;
+
+  queuedDuration: moment.Duration;
+
+  queuedDurationUnit: number = 0;
+
+  constructor(
+    instance: TaskInstance,
+    runDuration: moment.Duration,
+    queuedDuration: moment.Duration,
+    dataIntervalStart: string,
+    dataIntervalEnd: string,
+    executionDate: string
+  ) {
+    this.instance = instance;
+    this.runDuration = runDuration;
+    this.queuedDuration = queuedDuration;
+    this.dataIntervalStart = dataIntervalStart;
+    this.dataIntervalEnd = dataIntervalEnd;
+    this.executionDate = executionDate;
+  }
+}
+
+const TaskDuration = () => {
+  const {
+    selected: { taskId },
+    onSelect,
+  } = useSelection();
+
+  const {
+    data: { dagRuns, groups },
+  } = useGridData();
+  let maxDuration = 0;
+  let unit = "seconds";
+  const durations: TaskInstanceDuration[] = [];
+
+  const hasTaskInstances =
+    groups.children &&
+    groups.children &&
+    groups.children.find((child) => child.id === taskId);

Review Comment:
   This doesn't work with task groups. Use the `getTask()` util function. And 
then on Line 84, we can do `task.taskInstances.map()` instead of iterating over 
every dagRun. That should simplify the code quite a bit.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to