From 9ba09adb156a8ee52b919f2272deaa3181b47aaf Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Thu, 24 Oct 2024 09:40:06 -0700 Subject: [PATCH 1/2] Sort the assets by creation time in the version endpoint, just like /assets We made the asset list in the GET version endpoint more useful recently by including the asset-id. But that list is not being sorted by creation time, unlike the list provided by /assets, so the assets are somewhat randomly ordered. So, add the change to sort the asset list of the GET version endpoint by creation time. This ensures that the default asset is always first, etc. --- app/routes/datasets/versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/routes/datasets/versions.py b/app/routes/datasets/versions.py index 89a2f172..085877ca 100644 --- a/app/routes/datasets/versions.py +++ b/app/routes/datasets/versions.py @@ -536,6 +536,7 @@ async def _version_response( .where(ORMAsset.dataset == dataset) .where(ORMAsset.version == version) .where(ORMAsset.status == AssetStatus.saved) + .order_by(ORMAsset.created_on) .gino.all() ) data = Version.from_orm(data).dict(by_alias=True) From 674ca770e74f7e36522099f8bda4296ca4fefdf8 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Thu, 24 Oct 2024 12:01:54 -0700 Subject: [PATCH 2/2] Add doc comments to indicate asset list is sorted by creation time. Updating doc based on good comment from Gary. --- app/routes/datasets/asset.py | 3 ++- app/routes/datasets/versions.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/routes/datasets/asset.py b/app/routes/datasets/asset.py index 66f81d9f..862a6eb8 100644 --- a/app/routes/datasets/asset.py +++ b/app/routes/datasets/asset.py @@ -66,7 +66,8 @@ async def get_version_assets( description="The number of assets per page. Default is `10`.", ), ) -> Union[PaginatedAssetsResponse, AssetsResponse]: - """Get all assets for a given dataset version. + """Get all assets for a given dataset version. The list of assets + is sorted by the creation time of each asset. Will attempt to paginate if `page[size]` or `page[number]` is provided. Otherwise, it will attempt to return the entire list of diff --git a/app/routes/datasets/versions.py b/app/routes/datasets/versions.py index 085877ca..d25175b5 100644 --- a/app/routes/datasets/versions.py +++ b/app/routes/datasets/versions.py @@ -81,7 +81,8 @@ async def get_version( *, dv: Tuple[str, str] = Depends(dataset_version_dependency) ) -> VersionResponse: - """Get basic metadata for a given version.""" + """Get basic metadata for a given version. The list of assets is sorted by + the creation time of each asset.""" dataset, version = dv row: ORMVersion = await versions.get_version(dataset, version)