mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
jira-15 leader board API and profile API
This commit is contained in:
@ -143,7 +143,7 @@ class SearchTaskListAPIView(viewsets.ModelViewSet):
|
||||
class TopJuniorListAPIView(viewsets.ModelViewSet):
|
||||
"""Top juniors list"""
|
||||
serializer_class = TopJuniorSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
# permission_classes = [IsAuthenticated]
|
||||
queryset = JuniorPoints.objects.all()
|
||||
|
||||
def get_serializer_context(self):
|
||||
@ -152,8 +152,14 @@ class TopJuniorListAPIView(viewsets.ModelViewSet):
|
||||
return context
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""fetch junior list those complete their task"""
|
||||
"""Fetch junior list of those who complete their tasks"""
|
||||
junior_total_points = self.get_queryset().order_by('-total_task_points')
|
||||
|
||||
# Update the position field for each JuniorPoints object
|
||||
for index, junior in enumerate(junior_total_points):
|
||||
junior.position = index + 1
|
||||
junior.save()
|
||||
|
||||
serializer = self.get_serializer(junior_total_points, many=True)
|
||||
return custom_response(serializer.data, response_status=status.HTTP_200_OK)
|
||||
|
||||
|
Reference in New Issue
Block a user