youngduck98 commented on code in PR #75608:
URL: https://github.com/apache/airflow/pull/75608#discussion_r4495063929
##########
airflow-core/src/airflow/ui/src/pages/Run/DeadlineStatus.tsx:
##########
@@ -23,67 +23,62 @@ import dayjs from "dayjs";
import { useTranslation } from "react-i18next";
import { FiAlertTriangle, FiCheck, FiClock } from "react-icons/fi";
-import { useDeadlinesServiceGetDagDeadlineAlerts,
useDeadlinesServiceGetDeadlines } from "openapi/queries";
-import type { DeadlineAlertResponse } from "openapi/requests/types.gen";
+import { useDeadlinesServiceGetDeadlines } from "openapi/queries";
+import type { DAGRunResponse, DeadlineAlertResponse } from
"openapi/requests/types.gen";
import { Tooltip } from "src/system-components";
import Time from "src/components/Time";
import { useDurationFormat } from "src/utils";
-import { translateCompletionRule } from "src/utils/deadlines";
+import { isDeadlineAlertApplicable, translateCompletionRule } from
"src/utils/deadlines";
import { DeadlineStatusModal } from "./DeadlineStatusModal";
type DeadlineStatusProps = {
readonly dagId: string;
readonly dagRunId: string;
readonly endDate: string | null;
+ readonly runType: DAGRunResponse["run_type"];
};
-export const DeadlineStatus = ({ dagId, dagRunId, endDate }:
DeadlineStatusProps) => {
+export const DeadlineStatus = ({ dagId, dagRunId, endDate, runType }:
DeadlineStatusProps) => {
const { t: translate } = useTranslation("dag");
const { locale, renderDuration } = useDurationFormat();
const [isModalOpen, setIsModalOpen] = useState(false);
const { data: deadlineData, isLoading: isLoadingDeadlines } =
useDeadlinesServiceGetDeadlines({
dagId,
dagRunId,
+ includeAlerts: true,
limit: 10,
orderBy: ["deadline_time"],
});
-
- // Used to detect whether the DAG has any deadline alerts at all, so we can
show "Met" when there are alerts configured but no active deadline instances.
- const { data: alertData, isLoading: isLoadingAlerts } =
useDeadlinesServiceGetDagDeadlineAlerts({
- dagId,
- limit: 100,
- });
+ const applicableAlerts = (deadlineData?.deadline_alerts ??
[]).filter((deadlineAlert) =>
+ isDeadlineAlertApplicable(deadlineAlert, runType),
+ );
Review Comment:
Added a `DeadlineStatus` test in
[f17794f113](https://github.com/apache/airflow/pull/75608/commits/f17794f113e4d2ae42892117738864ee4ab6738e).
For a manual run with no deadline records, it checks that the tooltip includes
the matching and unrestricted alert rules and excludes the scheduled-only rule.
In
[6cc1dfc6ae](https://github.com/apache/airflow/pull/75608/commits/6cc1dfc6aeaf8caaecd876cb9280d576a0c9f8e2),
I also added a case where `manual` is the second value in the filter, plus a
backend test that checks the exact alert IDs used to create deadlines when a
Dag has a mix of filters.
--
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]