This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v3-0-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 4cc590d559e54bc0aaee16d8e016b2fbdbe90d16 Author: Guan Ming(Wesley) Chiu <[email protected]> AuthorDate: Thu May 1 02:16:59 2025 +0800 refactor: migrate to new ui endpoint (#50028) (cherry picked from commit 129f07d26f01c0860339b3ec4c893ed5f65c4c35) --- .../airflow/ui/src/pages/Dashboard/Stats/Stats.tsx | 35 +++++++--------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/Stats.tsx b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/Stats.tsx index 085a348fa7a..03149103894 100644 --- a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/Stats.tsx +++ b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/Stats.tsx @@ -19,32 +19,17 @@ import { Box, Flex, Heading, HStack } from "@chakra-ui/react"; import { FiClipboard, FiZap } from "react-icons/fi"; -import { useDagServiceGetDags } from "openapi/queries"; +import { useDashboardServiceDagStats } from "openapi/queries"; import { DAGImportErrors } from "./DAGImportErrors"; import { StatsCard } from "./StatsCard"; export const Stats = () => { - const { data: activeDagsData, isLoading: isActiveDagsLoading } = useDagServiceGetDags({ - paused: false, - }); - - const { data: failedDagsData, isLoading: isFailedDagsLoading } = useDagServiceGetDags({ - lastDagRunState: "failed", - }); - - const { data: queuedDagsData, isLoading: isQueuedDagsLoading } = useDagServiceGetDags({ - lastDagRunState: "queued", - }); - - const { data: runningDagsData, isLoading: isRunningDagsLoading } = useDagServiceGetDags({ - lastDagRunState: "running", - }); - - const activeDagsCount = activeDagsData?.total_entries ?? 0; - const failedDagsCount = failedDagsData?.total_entries ?? 0; - const queuedDagsCount = queuedDagsData?.total_entries ?? 0; - const runningDagsCount = runningDagsData?.total_entries ?? 0; + const { data: statsData, isLoading: isStatsLoading } = useDashboardServiceDagStats(); + const failedDagsCount = statsData?.failed_dag_count ?? 0; + const queuedDagsCount = statsData?.queued_dag_count ?? 0; + const runningDagsCount = statsData?.running_dag_count ?? 0; + const activeDagsCount = statsData?.active_dag_count ?? 0; return ( <Box> @@ -59,7 +44,7 @@ export const Stats = () => { <StatsCard colorScheme="failed" count={failedDagsCount} - isLoading={isFailedDagsLoading} + isLoading={isStatsLoading} label="Failed dags" link="dags?last_dag_run_state=failed" state="failed" @@ -71,7 +56,7 @@ export const Stats = () => { <StatsCard colorScheme="queued" count={queuedDagsCount} - isLoading={isQueuedDagsLoading} + isLoading={isStatsLoading} label="Queued dags" link="dags?last_dag_run_state=queued" state="queued" @@ -81,7 +66,7 @@ export const Stats = () => { <StatsCard colorScheme="running" count={runningDagsCount} - isLoading={isRunningDagsLoading} + isLoading={isStatsLoading} label="Running dags" link="dags?last_dag_run_state=running" state="running" @@ -91,7 +76,7 @@ export const Stats = () => { colorScheme="blue" count={activeDagsCount} icon={<FiZap />} - isLoading={isActiveDagsLoading} + isLoading={isStatsLoading} label="Active dags" link="dags?paused=false" />
