guan404ming commented on code in PR #49794:
URL: https://github.com/apache/airflow/pull/49794#discussion_r2063667043


##########
airflow-core/src/airflow/ui/src/pages/Dashboard/PoolSummary/PoolSummary.tsx:
##########
@@ -0,0 +1,113 @@
+/*!
+ * 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.
+ */
+import { Box, Heading, Flex, Skeleton } from "@chakra-ui/react";
+import { BiTargetLock } from "react-icons/bi";
+
+import { usePoolServiceGetPools } from "openapi/queries/queries";
+import { Tooltip } from "src/components/ui";
+import { capitalize } from "src/utils";
+import { slots } from "src/utils/slots";
+
+export const PoolSummary = () => {
+  const { data, isLoading } = usePoolServiceGetPools();
+  const pools = data?.pools ?? [];
+  const totalSlots = pools.reduce((sum, pool) => sum + pool.slots, 0);
+
+  const slotTotals = {
+    deferred_slots: 0,
+    occupied_slots: 0,
+    open_slots: 0,
+    queued_slots: 0,
+    running_slots: 0,
+    scheduled_slots: 0,
+  };
+
+  const poolsWithSlotType = {
+    deferred_slots: 0,
+    occupied_slots: 0,
+    open_slots: 0,
+    queued_slots: 0,
+    running_slots: 0,
+    scheduled_slots: 0,
+  };
+
+  pools.forEach((pool) => {
+    Object.keys(slotTotals).forEach((slotKey) => {
+      const typedKey = slotKey as keyof typeof slotTotals;
+      const slotValue = pool[typedKey];
+
+      if (typeof slotValue === "number" && slotValue > 0) {

Review Comment:
   Since PoolResponse has some key is string type,
   ```js
   export type PoolResponse = {
     name: string;
     slots: number;
     description: string | null;
     include_deferred: boolean;
     occupied_slots: number;
     running_slots: number;
     queued_slots: number;
     scheduled_slots: number;
     open_slots: number;
     deferred_slots: number;
   };
   ```
   I think it would be better with some local type like
   ```js
   type Slots = Omit<PoolResponse, "description" | "include_deferred" | "name" 
| "slots">;
   ```



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