ashb commented on a change in pull request #14306:
URL: https://github.com/apache/airflow/pull/14306#discussion_r579284297



##########
File path: airflow/api_connexion/endpoints/dag_endpoint.py
##########
@@ -59,11 +59,21 @@ def get_dag_details(dag_id):
 
 @security.requires_access([(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG)])
 @format_parameters({'limit': check_limit})
-def get_dags(limit, offset=0):
+def get_dags(limit, offset=0, only_active=False):
     """Get all DAGs."""
     readable_dags = current_app.appbuilder.sm.get_readable_dags(g.user)
-    dags = 
readable_dags.order_by(DagModel.dag_id).offset(offset).limit(limit).all()
-    total_entries = readable_dags.count()
+    if only_active:
+        dags = (
+            readable_dags.filter(DagModel.is_active)
+            .order_by(DagModel.dag_id)
+            .offset(offset)
+            .limit(limit)
+            .all()
+        )
+        total_entries = readable_dags.filter(DagModel.is_active).count()
+    else:
+        dags = 
readable_dags.order_by(DagModel.dag_id).offset(offset).limit(limit).all()
+        total_entries = readable_dags.count()

Review comment:
       Easier way:
   
   ```suggestion
       if only_active:
           readable_dags = readable_dags.filter(DagModel.is_active)
       dags = 
readable_dags.order_by(DagModel.dag_id).offset(offset).limit(limit).all()
       total_entries = readable_dags.count()
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to