Skip to content

Commit

Permalink
Merge pull request #2196 from gtech-mulearn/dev-server
Browse files Browse the repository at this point in the history
Merge dev-server to production
  • Loading branch information
jelanmathewjames authored Aug 1, 2024
2 parents 99f4c1f + f8d7afc commit cde9392
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 17 additions & 2 deletions api/launchpad/launchpad_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@ def get(self, request):
["full_name", "karma", "org", "district_name", "state"]
)

final_users = paginated_queryset.get("queryset")
if request.query_params.get("search"):
final_users = list(final_users)
for user in final_users:
user.rank = next(rank_user.rank for rank_user in rank_list if rank_user.muid == user.muid)

serializer = LaunchpadLeaderBoardSerializer(
paginated_queryset.get("queryset"), many=True
final_users,
many=True
)

return CustomResponse().paginated_response(
data=serializer.data, pagination=paginated_queryset.get("pagination")
)
Expand Down Expand Up @@ -132,14 +140,21 @@ def get(self, request):
for index, user in enumerate(rank_list):
user.rank = index + 1


paginated_queryset = CommonUtils.get_paginated_queryset(
users,
request,
["full_name", "karma", "org", "district_name", "state"]
)

final_users = paginated_queryset.get("queryset")
if request.query_params.get("search"):
final_users = list(final_users)
for user in final_users:
user.rank = next(rank_user.rank for rank_user in rank_list if rank_user.muid == user.muid)

serializer = TaskCompletedLeaderBoardSerializer(
paginated_queryset.get("queryset"),
final_users,
many=True
)
return CustomResponse().paginated_response(
Expand Down
4 changes: 4 additions & 0 deletions api/launchpad/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Meta:


class TaskCompletedLeaderBoardSerializer(serializers.ModelSerializer):
# rank = serializers.SerializerMethodField('get_rank')
rank = serializers.IntegerField()
karma = serializers.IntegerField()
is_public = serializers.BooleanField(source='user_settings_user.is_public',default=False)
Expand All @@ -83,6 +84,9 @@ class TaskCompletedLeaderBoardSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ("muid", "is_public", "rank", "full_name", "karma", "org", "district_name", "state", "profile_pic")

def get_rank(self, obj):
return getattr(obj, 'rank', None)


class LaunchpadParticipantsSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit cde9392

Please sign in to comment.