Skip to content

Commit

Permalink
Merge pull request #597 from wri/sort_version_assets
Browse files Browse the repository at this point in the history
Sort the assets by creation time in the version endpoint, just like /assets
  • Loading branch information
danscales authored Oct 24, 2024
2 parents 8157344 + 674ca77 commit 50c4642
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/routes/datasets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion app/routes/datasets/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -536,6 +537,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)
Expand Down

0 comments on commit 50c4642

Please sign in to comment.