uranusjr commented on code in PR #31772:
URL: https://github.com/apache/airflow/pull/31772#discussion_r1231965045
##########
airflow/models/dagrun.py:
##########
@@ -283,17 +286,17 @@ def active_runs_of_dags(
session: Session = NEW_SESSION,
) -> dict[str, int]:
"""Get the number of active dag runs for each dag."""
- query = session.query(cls.dag_id, func.count("*"))
+ query = select(cls.dag_id, func.count("*"))
if dag_ids is not None:
# 'set' called to avoid duplicate dag_ids, but converted back to
'list'
# because SQLAlchemy doesn't accept a set here.
- query = query.filter(cls.dag_id.in_(set(dag_ids)))
+ query = query.where(cls.dag_id.in_(set(dag_ids)))
if only_running:
- query = query.filter(cls.state == State.RUNNING)
+ query = query.where(cls.state == State.RUNNING)
else:
- query = query.filter(cls.state.in_([State.RUNNING, State.QUEUED]))
+ query = query.where(cls.state.in_([State.RUNNING, State.QUEUED]))
query = query.group_by(cls.dag_id)
- return {dag_id: count for dag_id, count in query.all()}
+ return {dag_id: count for dag_id, count in
session.execute(query).all()}
Review Comment:
(I think this can actually be `dict(session.execute(query))` but a
comprehension is more readable.)
--
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]