bbovenzi commented on code in PR #26358:
URL: https://github.com/apache/airflow/pull/26358#discussion_r973665650
##########
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:
We may want to sort in a couple ways right? By name and by last updated at?
I think having the UI just default to desc was so that the latest changes are
what a user sees first.
--
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]