diff --git a/api/launchpad/launchpad_views.py b/api/launchpad/launchpad_views.py index e709b4be..ab91cfd2 100644 --- a/api/launchpad/launchpad_views.py +++ b/api/launchpad/launchpad_views.py @@ -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,