Skip to content

Commit

Permalink
Merge pull request #1996 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Update launchpad leaderboard serializers
  • Loading branch information
jelanmathewjames authored Jun 1, 2024
2 parents 97b1d20 + 36c3912 commit af071d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 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 Q, Sum, Max, Prefetch
from django.db.models import Q, Sum, Max, Prefetch, F
from django.db.models.functions import Coalesce

from rest_framework.views import APIView

Expand Down Expand Up @@ -32,6 +33,9 @@ def get(self, request):
karma_activity_log_user__appraiser_approved=True,
),
),
org=F("user_organization_link_user__org__title"),
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"),
)
.order_by("-karma", "time_")
Expand Down
6 changes: 3 additions & 3 deletions api/launchpad/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class LaunchpadLeaderBoardSerializer(serializers.ModelSerializer):
karma = serializers.IntegerField()
org = serializers.ReadOnlyField(source="user_organization_link_user.org.title")
district_name = serializers.ReadOnlyField(source="user_organization_link_user.org.district.name")
state = serializers.ReadOnlyField(source="user_organization_link_user.org.district.zone.state.name")
org = serializers.CharField()
district_name = serializers.CharField()
state = serializers.CharField()

class Meta:
model = User
Expand Down

0 comments on commit af071d8

Please sign in to comment.