You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/22 10:26:09 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #14895: Add REST API query sort and order to some endpoints

uranusjr commented on a change in pull request #14895:
URL: https://github.com/apache/airflow/pull/14895#discussion_r598591728



##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -142,8 +155,15 @@ def _fetch_dag_runs(
     )
     # Count items
     total_entries = query.count()
+    # sort
+    if sort == 'asc':
+        query = query.order_by(asc(order_by))
+    elif sort == 'desc':
+        query = query.order_by(desc(order_by))
+    else:
+        query = query.order_by(DagRun.id)

Review comment:
       I’d probably also handle `sort="desc", order_by=None` here by ordering desc by ID; same aplies for other changes. (Probably a good idea to somehow extract the logic to a function?)




-- 
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:
users@infra.apache.org