Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev-server to production #2196

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading