zmievsa commented on code in PR #48651:
URL: https://github.com/apache/airflow/pull/48651#discussion_r2029792618
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py:
##########
@@ -150,3 +152,27 @@ def get_dagrun_state(
)
return DagRunStateResponse(state=dag_run.state)
+
+
[email protected]("/count", status_code=status.HTTP_200_OK)
+def get_dr_count(
+ dag_id: str,
+ session: SessionDep,
+ logical_dates: Annotated[list[UtcDateTime] | None, Query()] = None,
+ run_ids: Annotated[list[str] | None, Query()] = None,
+ states: Annotated[list[str] | None, Query()] = None,
+) -> int:
+ """Get the count of DAG runs matching the given criteria."""
+ query = select(func.count()).select_from(DagRun).where(DagRun.dag_id ==
dag_id)
+
+ if logical_dates:
+ query = query.where(DagRun.logical_date.in_(logical_dates))
+
+ if run_ids:
+ query = query.where(DagRun.run_id.in_(run_ids))
+
+ if states:
+ query = query.where(DagRun.state.in_(states))
+
+ count = session.scalar(query)
+ return count or 0
Review Comment:
I'll make Cadwyn's docs more verbose on when it makes the most sense to add
a migration. Concepts section mostly focuses on what's possible with Cadwyn
while "how to" focuses on what you should actually do.
Either way 99% of the time it makes sense to add an endpoint to all versions
since it's not a breaking change :)
Update:
https://docs.cadwyn.dev/concepts/endpoint_migrations/#defining-endpoints-that-didnt-exist-in-old-versions
added a bunch of notes here and there about this.
--
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]