Skip to content

Commit

Permalink
Improve package list sorting priority
Browse files Browse the repository at this point in the history
Add upload date as the last sorting criteria for "Most Downloaded" and
"Top Rated" sorting options. This fixes an issue where packages with
equal amounts of ratings or downloads would get arbitrarily sorted in
search results, sometimes leading to a subset of the results never being
visible on any page (if a sufficiently large group of same-priority
sorting packages exists).

Thanks for keks307 on the Inscryption Modding discord for noticing this.

No refs
  • Loading branch information
MythicManiac committed Aug 30, 2023
1 parent 72a681d commit 6084644
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions django/thunderstore/repository/views/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def order_queryset(self, queryset):
"-package__is_pinned",
"package__is_deprecated",
"-total_downloads",
"-package__date_updated",
)
if active_ordering == "top-rated":
return queryset.annotate(
Expand All @@ -191,6 +192,7 @@ def order_queryset(self, queryset):
"-package__is_pinned",
"package__is_deprecated",
"-total_rating",
"-package__date_updated",
)
return queryset.order_by(
"-package__is_pinned",
Expand Down

0 comments on commit 6084644

Please sign in to comment.