bbovenzi commented on code in PR #62195: URL: https://github.com/apache/airflow/pull/62195#discussion_r3163677262
########## airflow-core/src/airflow/ui/src/queries/useDeadlines.ts: ########## @@ -0,0 +1,65 @@ +/*! + * 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 { useDeadlinesServiceGetDeadlines } from "openapi/queries"; + +type UseDeadlinesParams = { + readonly dagId: string; + readonly enabled?: boolean; + readonly endDate: string; + readonly limit: number; + readonly missed: boolean; + readonly offset?: number; + readonly refetchInterval?: number | false; Review Comment: So again, let's not drill the refetchInterval prop at all. Just call `useAuthRefresh` here. ########## airflow-core/src/airflow/ui/src/pages/Dag/Overview/DagDeadlines.tsx: ########## @@ -0,0 +1,207 @@ +/*! + * 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 { Badge, Box, Button, Flex, Heading, HStack, Separator, Skeleton, VStack } from "@chakra-ui/react"; +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { FiAlertTriangle, FiClock } from "react-icons/fi"; + +import { useDeadlinesServiceGetDagDeadlineAlerts } from "openapi/queries"; +import type { DeadlineAlertResponse } from "openapi/requests/types.gen"; +import { ErrorAlert } from "src/components/ErrorAlert"; +import { useDeadlines } from "src/queries/useDeadlines"; +import { useAutoRefresh } from "src/utils"; + +import { AllDeadlinesModal } from "./AllDeadlinesModal"; +import { DeadlineRow } from "./DeadlineRow"; + +const LIMIT = 5; + +type DagDeadlinesProps = { + readonly dagId: string; + readonly endDate: string; + readonly startDate: string; +}; + +export const DagDeadlines = ({ dagId, endDate, startDate }: DagDeadlinesProps) => { + const { t: translate } = useTranslation("dag"); + const refetchInterval = useAutoRefresh({ dagId }); + const [modalOpen, setModalOpen] = useState<"missed" | "pending" | undefined>(undefined); + + const { + data: pendingData, + error: pendingError, + isLoading: isPendingLoading, + } = useDeadlines({ + dagId, + endDate, + limit: LIMIT, + missed: false, + refetchInterval, + startDate, + }); + + const { + data: missedData, + error: missedError, + isLoading: isMissedLoading, + } = useDeadlines({ + dagId, Review Comment: Thinking about this again. We should just fetch the latest 10 deadlines regardless of pending or missed. Then this is all the same as the modal when it opens from the Header too. ########## airflow-core/src/airflow/ui/src/queries/useDeadlines.ts: ########## @@ -0,0 +1,65 @@ +/*! + * 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 { useDeadlinesServiceGetDeadlines } from "openapi/queries"; + +type UseDeadlinesParams = { + readonly dagId: string; + readonly enabled?: boolean; + readonly endDate: string; + readonly limit: number; + readonly missed: boolean; + readonly offset?: number; + readonly refetchInterval?: number | false; + readonly startDate: string; +}; + +export const useDeadlines = ({ + dagId, + enabled, + endDate, + limit, + missed, + offset = 0, + refetchInterval, + startDate, +}: UseDeadlinesParams) => + useDeadlinesServiceGetDeadlines( + missed + ? { + dagId, + dagRunId: "~", + lastUpdatedAtGte: startDate, + lastUpdatedAtLte: endDate, + limit, + missed: true, + offset, + orderBy: ["-last_updated_at"], + } + : { + dagId, + dagRunId: "~", + deadlineTimeGte: endDate, + limit, + missed: false, + offset, + orderBy: ["deadline_time"], + }, + undefined, + { enabled, refetchInterval }, Review Comment: When we don't separate out missed and pending, we can check our refresh against if any of the latest deadlines are pending `refetchInterval : (query) => CHECK IF ANY ARE PENDING ? refetchInterval : false` ########## airflow-core/src/airflow/ui/public/i18n/locales/en/dag.json: ########## @@ -40,6 +40,31 @@ "parseDuration": "Parse Duration:", "parsedAt": "Parsed at:" }, + "deadlineAlerts": { + "completionRule": "Must complete within {{interval}} of {{reference}}", + "count_one": "{{count}} deadline", + "count_other": "{{count}} deadlines", + "referenceType": { + "AverageRuntimeDeadline": "average runtime", + "DagRunLogicalDateDeadline": "logical date", + "DagRunQueuedAtDeadline": "queue time" + }, + "title": "Deadline Alerts" + }, + "deadlineStatus": { + "actual": "Actual", + "expected": "Expected", + "finishedEarly": "Finished {{duration}} before deadline", + "finishedLate": "Finished {{duration}} after deadline", + "label": "Deadline", + "met": "Met", + "missed": "Missed", + "missedCount_one": "{{count}} Missed Deadline", + "missedCount_other": "{{count}} Missed Deadlines", + "stillRunning": "Still running", + "upcoming": "Upcoming", + "viewAll": "View all {{count}}" Review Comment: ```suggestion ``` Let's drop this key too and just have the count inside the deadline badge -- 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]
