You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jsjasonseba (via GitHub)" <gi...@apache.org> on 2025/04/16 15:35:39 UTC

[PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

jsjasonseba opened a new pull request, #49361:
URL: https://github.com/apache/airflow/pull/49361

   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   closes: https://github.com/apache/airflow/issues/49135
   ### Issue Summary
   Dag List page have missing last DAG runs on some DAGs. 
   Currently, the frontend logic calls `dags` from public API to fetch list of DAGs. However, the public API does not include last DAG run, so an additional API call to `recent_dag_runs` from UI API is necessary. 
   
   The issue stems from unmatched search params from both calls causing different set of DAGs returned causing missing last run.
   
   ### Solution
   1. Include order_by param to `recent_dag_runs` call which previously is not included
   2. Set dag_runs_limit to 1 (was 14) - as proposed in https://github.com/apache/airflow/issues/49135#issuecomment-2809566654. This ensures we only fetch one DagRun per DAG instead of applying the final `limit` across multiple runs.
   3. During further testing, I found that step 2 alone isn’t enough. If some DAGs don’t have any runs, the limits and offsets won’t align properly. To fix this, this PR changed the join logic so the query now starts from DAGModel and does a LEFT JOIN to recent runs. This ensures pagination works at the DAG level and includes DAGs with no runs. After pagination is done the DAGs with no runs is excluded from final response.
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049248884


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   I've been thinking again about doing the pagination on DagModel first before joining to get recent DAG runs. However, this ends up duplicating the logic of the `dags` endpoint from the public API
   
   At this point, it might make more sense to create a separate DAGs list endpoint specifically for the UI, with recent DAG runs already pre-joined, separating concerns from the public API.
   
   Let me know what you think @pierrejeambrun @bbovenzi 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049350564


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Actually that's a great question, because the current `recent_dag_runs` endpoints is exactly that. I admit the name is bad, but it actually list Dags, which is a `DAGResponse` with an extra for `latest_dag_runs`.
   
   So the UI should basically never use the public dag listing endpoint but only this one.
   
   Why is `useDags` doing some kind of weird join in the front-ent ? (there-fore mismatch happens), that's because I assume the private endpoint is missing some query parameters (search, filter, etc....).
   
   What we should do is improve that ui endpoint. (And maybe rename it to `ui/dags`) instead to avoid the confusion, to allow the same sorting, ordering searching as we do for the `api/v2/dags` one. Then we can refactor the `useDags` custom hook to only request that ui endpoint.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047361332


##########
airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml:
##########
@@ -203,6 +203,13 @@ paths:
           - $ref: '#/components/schemas/DagRunState'
           - type: 'null'
           title: Last Dag Run State
+      - name: order_by
+        in: query
+        required: false
+        schema:
+          type: string
+          default: dag_id
+          title: Order By

Review Comment:
   Nice. yes this was one of the issues before. Good call



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on PR #49361:
URL: https://github.com/apache/airflow/pull/49361#issuecomment-2809974545

   Hey @pierrejeambrun , I finally got it working with a few small tweaks. Feel free to take a look and share any feedback!


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047363230


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Does this not result in the DagCard only ever showing a single dagrun in its RecentRuns bar chart?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049423422


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Thanks, this really helps clarify things. I agree with your perspective on this. Let me work something out.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi closed pull request #49361: Fix missing last DAG run caused by incorrect parameters and join logic
URL: https://github.com/apache/airflow/pull/49361


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2058869003


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Thanks. Yes, I would love to remove this custom `useDags` hook to merge the two endpoints in the frontend and only use our ui specific endpoint



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #49361:
URL: https://github.com/apache/airflow/pull/49361#issuecomment-2949447226

   Good call. Going to close.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047373487


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Ah right, forgot about the bar chart, nice catch! I guess we can pass diferent values for BarChart



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047397594


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Right, forgot about the DagCard. I guess we need to find another way. One approach I can think of is to fix this from the backend side by using the dense_rank window function partitioned by dag_id and using the rank to apply offset and limit based on that. But, to be honest, it's a bit hacky.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #49361:
URL: https://github.com/apache/airflow/pull/49361#issuecomment-2855903255

   @jsjasonseba Looks like tests are failing


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on PR #49361:
URL: https://github.com/apache/airflow/pull/49361#issuecomment-2949443593

   The linked issue https://github.com/apache/airflow/issues/49135 was closed by https://github.com/apache/airflow/pull/51115 . Probably this PR can be closed.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047397594


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Right, forgot about the DagCard. I guess we need to find another way. ~~One approach I can think of is to fix this from the backend side by using the dense_rank window function partitioned by dag_id and using the rank to apply offset and limit based on that. But, to be honest, it's a bit hacky.~~
   
   Let's try a different approach on backend. We filter and paginate from DAGModel first then we do joins with the recent_dag_runs subquery.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047406026


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Yeah, I'd like us to stick to a single endpoint. Maybe down the road we can merge the next run assets info too. 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047909400


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   I totally forgot about the dag card too.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049248884


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   I've been thinking again about doing the pagination on DagModel first before joining to get recent DAG runs. However, this ends up duplicating the logic of the `dags` endpoint from the public API, which I don't think is an ideal solution either.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049350564


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Actually that's a great question, because the current `recent_dag_runs` endpoints is exactly that. I admit the name is bad, but it actually list Dags, which is a `DAGResponse` with an extra field for `latest_dag_runs`.
   
   So the UI should basically never use the public dag listing endpoint but only this one.
   
   Why is `useDags` doing some kind of weird join in the front-ent ? (there-fore mismatch happens), that's because I assume the private endpoint is missing some query parameters (search, filter, etc....).
   
   What we should do is improve that ui endpoint. (And maybe rename it to `ui/dags`) instead to avoid the confusion, to allow the same sorting, ordering searching as we do for the `api/v2/dags` one. Then we can refactor the `useDags` custom hook to only request that ui endpoint.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2049350564


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Actually that's a great question, because the current `recent_dag_runs` endpoints was supposed to be exactly that . I admit the name is bad, but it actually list Dags, which is a `DAGResponse` with an extra field for `latest_dag_runs`.
   
   So the UI should basically never use the public dag listing endpoint but only this one.
   
   Why is `useDags` doing some kind of weird join in the front-ent ? (there-fore mismatch happens), that's because I assume the private endpoint is missing some query parameters (search, filter, etc....).
   
   What we should do is improve that ui endpoint. (And maybe rename it to `ui/dags`) instead to avoid the confusion, to allow the same sorting, ordering searching as we do for the `api/v2/dags` one. Then we can refactor the `useDags` custom hook to only request that ui endpoint.



##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   >At this point, it might make more sense to create a separate DAGs list endpoint specifically for the UI, with recent DAG runs already pre-joined, separating concerns from the public API.
   
   
   
   Actually that's a great question, because the current `recent_dag_runs` endpoints was supposed to be exactly that . I admit the name is bad, but it actually list Dags, which is a `DAGResponse` with an extra field for `latest_dag_runs`.
   
   So the UI should basically never use the public dag listing endpoint but only this one.
   
   Why is `useDags` doing some kind of weird join in the front-ent ? (there-fore mismatch happens), that's because I assume the private endpoint is missing some query parameters (search, filter, etc....).
   
   What we should do is improve that ui endpoint. (And maybe rename it to `ui/dags`) instead to avoid the confusion, to allow the same sorting, ordering searching as we do for the `api/v2/dags` one. Then we can refactor the `useDags` custom hook to only request that ui endpoint.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix missing last DAG run caused by incorrect parameters and join logic [airflow]

Posted by "jsjasonseba (via GitHub)" <gi...@apache.org>.
jsjasonseba commented on code in PR #49361:
URL: https://github.com/apache/airflow/pull/49361#discussion_r2047373487


##########
airflow-core/src/airflow/ui/src/queries/useDags.tsx:
##########
@@ -42,16 +42,15 @@ export const useDags = (
 
   const refetchInterval = useAutoRefresh({});
 
-  const { orderBy, ...runsParams } = searchParams;
   const {
     data: runsData,
     error: runsError,
     isFetching: isRunsFetching,
     isLoading: isRunsLoading,
   } = useDagsServiceRecentDagRuns(
     {
-      ...runsParams,
-      dagRunsLimit: 14,
+      ...searchParams,
+      dagRunsLimit: 1,

Review Comment:
   Ah right, forgot about the bar chart, nice catch! I guess we can pass diferent values for BarChart



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org