Skip to content

Commit

Permalink
Update dandiapi/api/views/dandiset.py
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Nesbitt <[email protected]>
  • Loading branch information
bendichter and jjnesbitt authored Dec 29, 2024
1 parent 655e3a4 commit 988888d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dandiapi/api/views/dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def filter_queryset(self, request, queryset, view):
return queryset.order_by(ordering)
if ordering.endswith('stars'):
queryset = queryset.annotate(stars_count=Count('stars'))
return queryset.order_by(f"{'-' if ordering.startswith('-') else ''}stars_count")
prefix = '-' if ordering.startswith('-') else ''
return queryset.order_by(f"{prefix}stars_count")
return queryset


Expand Down

0 comments on commit 988888d

Please sign in to comment.