pierrejeambrun commented on code in PR #50984:
URL: https://github.com/apache/airflow/pull/50984#discussion_r2106939610
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -115,30 +116,54 @@ def get_dags(
session: SessionDep,
) -> DAGCollectionResponse:
"""Get all DAGs."""
- dag_runs_select = None
+ query = select(DagModel)
- if dag_run_state.value or dag_run_start_date_range.is_active() or
dag_run_end_date_range.is_active():
- dag_runs_select, _ = paginated_select(
- statement=select(DagRun),
+ max_run_id_query = ( # ordering by id will not always be "latest run",
but it's a simplifying assumption
+ select(DagRun.dag_id, func.max(DagRun.id).label("max_dag_run_id"))
+ .where(DagRun.start_date.is_not(null()))
+ .group_by(DagRun.dag_id)
+ .subquery(name="mrq")
Review Comment:
The subquery name doesn't seem used. Also just from a db debugging
perspective (inspect the output sql statement)`mrq` without context doesn't
mean anything.
I think we should remove it.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -115,30 +116,54 @@ def get_dags(
session: SessionDep,
) -> DAGCollectionResponse:
"""Get all DAGs."""
- dag_runs_select = None
+ query = select(DagModel)
- if dag_run_state.value or dag_run_start_date_range.is_active() or
dag_run_end_date_range.is_active():
- dag_runs_select, _ = paginated_select(
- statement=select(DagRun),
+ max_run_id_query = ( # ordering by id will not always be "latest run",
but it's a simplifying assumption
+ select(DagRun.dag_id, func.max(DagRun.id).label("max_dag_run_id"))
+ .where(DagRun.start_date.is_not(null()))
+ .group_by(DagRun.dag_id)
+ .subquery(name="mrq")
Review Comment:
nit: The subquery name doesn't seem used. Also just from a db debugging
perspective (inspect the output sql statement)`mrq` without context doesn't
mean anything.
I think we should remove it.
--
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]