current page update in article api

This commit is contained in:
jain
2023-08-10 15:30:46 +05:30
parent 7a9be0326a
commit 69723b362f
8 changed files with 78 additions and 14 deletions

View File

@ -270,14 +270,12 @@ class TopJuniorListAPIView(viewsets.ModelViewSet):
"""Fetch junior list of those who complete their tasks"""
try:
junior_total_points = self.get_queryset().order_by('-total_points')
# Update the position field for each JuniorPoints object
for index, junior in enumerate(junior_total_points):
junior.position = index + 1
send_notification.delay(LEADERBOARD_RANKING, None, junior.junior.auth.id, {})
junior.save()
serializer = self.get_serializer(junior_total_points, many=True)
serializer = self.get_serializer(junior_total_points[:15], many=True)
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
except Exception as e:
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)