Skip to content

Commit

Permalink
Merge pull request #2042 from jelanmathewjames/dev
Browse files Browse the repository at this point in the history
fix rank anomaly
  • Loading branch information
jelanmathewjames authored Jun 11, 2024
2 parents 345561d + b9b74cc commit 03202fe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions api/launchpad/launchpad_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def get(self, request):
district_name=F("user_organization_link_user__org__district__name"),
state=F("user_organization_link_user__org__district__zone__state__name"),
time_=Max("karma_activity_log_user__created_at"),
).annotate(
).order_by("-karma", "time_")

users = users.annotate(
rank=Window(
expression=RowNumber(),
order_by=[F('karma').desc(), F('time_').asc()]
order_by=F("karma").desc(),
)
).order_by("-karma", "time_")

).order_by("rank")
paginated_queryset = CommonUtils.get_paginated_queryset(
users,
request,
Expand Down

0 comments on commit 03202fe

Please sign in to comment.