https://github.com/apache/airflow/blob/main/airflow/cli/commands/task_command.py#L145
cls,
        dag_ids: Iterable[str] | None = None,
        only_running: bool = False,
        session: Session = NEW_SESSION,
    ) -> dict[str, int]:
        """Get the number of active dag runs for each dag."""
        query = select(cls.dag_id, func.count("*"))
        if dag_ids is not None:
            
            
            query = query.where(cls.dag_id.in_(set(dag_ids)))
        if only_running:
            query = query.where(cls.state == DagRunState.RUNNING)
        else:
            query = query.where(cls.state.in_((DagRunState.RUNNING, DagRunState.QUEUED)))
        query = query.group_by(cls.dag_id)
        return dict(iter(session.execute(query)))
    @classmethod
    def next_dagruns_to_examine(