diff --git a/dandiapi/api/tests/test_dandiset.py b/dandiapi/api/tests/test_dandiset.py index 1dbf86355..7a64181c9 100644 --- a/dandiapi/api/tests/test_dandiset.py +++ b/dandiapi/api/tests/test_dandiset.py @@ -99,10 +99,10 @@ def test_dandiset_rest_list(api_client, user, dandiset): [ ('', ['empty', 'draft', 'published', 'erased']), ('?draft=false', ['published', 'erased']), - ('?empty=false', ['draft', 'published']), + ('?empty=false', ['draft', 'published', 'erased']), ('?draft=true&empty=true', ['empty', 'draft', 'published', 'erased']), ('?empty=true&draft=true', ['empty', 'draft', 'published', 'erased']), - ('?draft=false&empty=false', ['published']), + ('?draft=false&empty=false', ['published', 'erased']), ], ids=[ 'nothing', diff --git a/dandiapi/api/views/dandiset.py b/dandiapi/api/views/dandiset.py index 0e6790ee3..4dea82aec 100644 --- a/dandiapi/api/views/dandiset.py +++ b/dandiapi/api/views/dandiset.py @@ -144,13 +144,13 @@ def get_queryset(self): # Only include dandisets that have assets in their most recent version. most_recent_version = ( Version.objects.filter(dandiset=OuterRef('pk')) - .order_by('created') + .order_by('-created') .annotate(asset_count=Count('assets'))[:1] ) queryset = queryset.annotate( - draft_asset_count=Subquery(most_recent_version.values('asset_count')) + asset_count=Subquery(most_recent_version.values('asset_count')) ) - queryset = queryset.filter(draft_asset_count__gt=0) + queryset = queryset.filter(asset_count__gt=0) if not show_embargoed: queryset = queryset.filter(embargo_status='OPEN') return queryset