seanghaeli commented on code in PR #76567:
URL: https://github.com/apache/airflow/pull/76567#discussion_r4488379302


##########
airflow-core/src/airflow/ui/src/pages/Trigger/ScheduledDags.tsx:
##########
@@ -0,0 +1,58 @@
+/*!
+ * 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 { HStack, Skeleton, Text } from "@chakra-ui/react";
+import { useQueries } from "@tanstack/react-query";
+import { useTranslation } from "react-i18next";
+
+import { UseAssetServiceGetAssetKeyFn } from "openapi/queries/common";
+import { AssetService } from "openapi/requests/services.gen";
+
+import { RouterLink } from "src/system-components";
+
+/** The Dags scheduled on the watched assets, as each asset lists them: only 
the Dags the user can read. */
+export const ScheduledDags = ({ assetIds }: { readonly assetIds: Array<number> 
}) => {
+  const { t: translate } = useTranslation("browse");
+  const assets = useQueries({
+    queries: assetIds.map((assetId) => ({
+      queryFn: () => AssetService.getAsset({ assetId }),
+      queryKey: UseAssetServiceGetAssetKeyFn({ assetId }),
+    })),
+  });
+
+  if (assets.some(({ isLoading }) => isLoading)) {
+    return <Skeleton height={5} width="200px" />;
+  }
+
+  const dagIds = [
+    ...new Set(assets.flatMap(({ data }) => (data?.scheduled_dags ?? 
[]).map(({ dag_id: dagId }) => dagId))),

Review Comment:
   Done, it reads `scheduled_dag_ids` off the trigger now and the per-asset 
`GET /assets/{id}` fetch is gone.



##########
airflow-core/src/airflow/ui/src/pages/Trigger/ScheduledDags.tsx:
##########
@@ -0,0 +1,58 @@
+/*!
+ * 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 { HStack, Skeleton, Text } from "@chakra-ui/react";
+import { useQueries } from "@tanstack/react-query";
+import { useTranslation } from "react-i18next";
+
+import { UseAssetServiceGetAssetKeyFn } from "openapi/queries/common";
+import { AssetService } from "openapi/requests/services.gen";
+
+import { RouterLink } from "src/system-components";
+
+/** The Dags scheduled on the watched assets, as each asset lists them: only 
the Dags the user can read. */
+export const ScheduledDags = ({ assetIds }: { readonly assetIds: Array<number> 
}) => {
+  const { t: translate } = useTranslation("browse");
+  const assets = useQueries({
+    queries: assetIds.map((assetId) => ({
+      queryFn: () => AssetService.getAsset({ assetId }),
+      queryKey: UseAssetServiceGetAssetKeyFn({ assetId }),
+    })),
+  });

Review Comment:
   Did a pass. That `useQueries` was the only hand-built one and it went away 
with the change above. I also dropped the `useTriggerDetail` wrapper, so the 
trigger pages call `useTriggerServiceGetTrigger` directly.



##########
airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/FailingTriggers.tsx:
##########
@@ -0,0 +1,46 @@
+/*!
+ * 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 { useTranslation } from "react-i18next";
+
+import { useTriggerServiceGetTriggers } from "openapi/queries";
+
+import { StatsCard } from "src/components/StatsCard";
+
+import { useAutoRefresh } from "src/utils";
+
+/** Failing and orphaned triggers; hidden when there are none, or none the 
user can see (a 403). */
+export const FailingTriggers = () => {
+  const { i18n, t: translate } = useTranslation("dashboard");
+  const refetchInterval = useAutoRefresh({});
+  const { data } = useTriggerServiceGetTriggers({ limit: 1, status: 
["failing", "orphaned"] }, undefined, {

Review Comment:
   Dropping orphaned out of this, since it doesn't really need a user's 
attention, it will get picked up by another triggerer.



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