bbovenzi commented on code in PR #46296:
URL: https://github.com/apache/airflow/pull/46296#discussion_r1937452311
##########
airflow/ui/src/pages/Dag/Dag.tsx:
##########
@@ -42,20 +44,46 @@ export const Dag = () => {
dagId,
});
+ const refetchInterval = useAutoRefresh({ dagId });
+
// TODO: replace with with a list dag runs by dag id request
const {
data: runsData,
error: runsError,
isLoading: isLoadingRuns,
} = useDagsServiceRecentDagRuns({ dagIds: [dagId] }, undefined, {
enabled: Boolean(dagId),
+ refetchInterval: (query) =>
+ query.state.data?.dags
+ .find((recentDag) => recentDag.dag_id === dagId)
+ ?.latest_dag_runs.some((run) => isStatePending(run.state))
+ ? refetchInterval
+ : false,
});
- const runs = runsData?.dags.find((dagWithRuns) => dagWithRuns.dag_id ===
dagId)?.latest_dag_runs ?? [];
+ const dagWithRuns = runsData?.dags.find((recentDag) => recentDag.dag_id ===
dagId);
return (
<DetailsLayout dag={dag} error={error ?? runsError} isLoading={isLoading
|| isLoadingRuns} tabs={tabs}>
- <Header dag={dag} dagId={dagId} latestRun={runs[0]} />
+ <Header
+ dag={
+ dag
+ ? ({
+ ...dag,
+ // We only need to refresh latest runs and next run
+ latest_dag_runs: dagWithRuns?.latest_dag_runs,
+ next_dagrun: dagWithRuns?.next_dagrun,
+ next_dagrun_create_after:
dagWithRuns?.next_dagrun_create_after,
+ next_dagrun_data_interval_end:
dagWithRuns?.next_dagrun_data_interval_end,
+ next_dagrun_data_interval_start:
dagWithRuns?.next_dagrun_data_interval_start,
+ } as DAGDetailsResponse & DAGWithLatestDagRunsResponse)
+ : undefined
+ }
Review Comment:
I can split it apart again.
--
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]