Skip to content

Commit

Permalink
Merge pull request #2033 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Merge dev to dev-server
  • Loading branch information
jelanmathewjames authored Jun 7, 2024
2 parents a94e050 + 3f1e323 commit 6670356
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/launchpad/launchpad_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db.models import Sum, Max, Prefetch, F, OuterRef, Subquery, IntegerField
from django.db.models import Sum, Max, Prefetch, F, OuterRef, Subquery, Window, IntegerField
from django.db.models.functions import RowNumber
from django.db import connection
from rest_framework.views import APIView

Expand Down Expand Up @@ -47,6 +48,11 @@ 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(
rank=Window(
expression=RowNumber(),
order_by=F('karma').desc(), F('time_').asc()
)
).order_by("-karma", "time_")

paginated_queryset = CommonUtils.get_paginated_queryset(
Expand Down

0 comments on commit 6670356

Please sign in to comment.