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 2022/09/15 20:34:57 UTC

[GitHub] [airflow] blag commented on a diff in pull request #26358: Dataset List View

blag commented on code in PR #26358:
URL: https://github.com/apache/airflow/pull/26358#discussion_r972397892


##########
airflow/www/views.py:
##########
@@ -3547,6 +3553,109 @@ def dataset_dependencies(self):
             {'Content-Type': 'application/json; charset=utf-8'},
         )
 
+    # @format_parameters({'limit': check_limit})
+    @expose('/object/list_datasets')
+    @auth.has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DATASET)])
+    def get_datasets(self):
+        """Get datasets"""
+        allowed_attrs = ['uri', 'last_dataset_update']
+
+        limit = int(request.args.get("limit", 25))
+        offset = int(request.args.get("offset", 0))
+        order_by = request.args.get("order_by", "uri")
+        lstripped_orderby = order_by.lstrip('-')
+
+        if lstripped_orderby not in allowed_attrs:
+            return {
+                "detail": (
+                    f"Ordering with '{lstripped_orderby}' is disallowed or the attribute does not "
+                    "exist on the model"
+                )
+            }, 400
+
+        limit = 50 if limit > 50 else limit
+
+        with create_session() as session:
+            if lstripped_orderby == "uri":
+                if order_by[0] == "-":
+                    order_by = (DatasetModel.uri.desc(),)
+                else:
+                    order_by = (DatasetModel.uri.asc(),)
+            elif lstripped_orderby == "last_dataset_update":

Review Comment:
   The [default order](https://github.com/apache/airflow/pull/26358/files#diff-5ed4b421389b931608cae97949c8e129aa9d4076e52d71a9e7f1b42ff49f77a5R75) is `-last_dataset_update`, but we do not yet have a way for users to explicitly sort this way in the UI.
   
   I can attempt to add this in, or we can add it in later.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org