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:
@ -5,7 +5,7 @@ from django.contrib.auth.models import User
|
||||
from django.db import transaction
|
||||
import random
|
||||
"""Import django app"""
|
||||
from junior.models import Junior
|
||||
from junior.models import Junior, JuniorPoints
|
||||
from guardian.utils import upload_image_to_alibaba
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from guardian.models import Guardian, JuniorTask
|
||||
@ -147,6 +147,7 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
||||
requested_task = serializers.SerializerMethodField('get_requested_task')
|
||||
rejected_task = serializers.SerializerMethodField('get_rejected_task')
|
||||
pending_task = serializers.SerializerMethodField('get_pending_task')
|
||||
position = serializers.SerializerMethodField('get_position')
|
||||
|
||||
|
||||
def get_auth(self, obj):
|
||||
@ -162,6 +163,11 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
||||
data = JuniorTask.objects.filter(junior=obj).count()
|
||||
return data
|
||||
|
||||
def get_position(self, obj):
|
||||
data = JuniorPoints.objects.filter(junior=obj).last()
|
||||
if data:
|
||||
return data.position
|
||||
return 99999
|
||||
def get_points(self, obj):
|
||||
data = sum(JuniorTask.objects.filter(junior=obj, task_status=COMPLETED).values_list('points', flat=True))
|
||||
return data
|
||||
@ -192,7 +198,7 @@ class JuniorDetailListSerializer(serializers.ModelSerializer):
|
||||
fields = ['id', 'email', 'first_name', 'last_name', 'country_code', 'phone', 'gender', 'dob',
|
||||
'guardian_code', 'referral_code','is_active', 'is_complete_profile', 'created_at', 'image',
|
||||
'updated_at', 'assigned_task','points', 'pending_task', 'in_progress_task', 'completed_task',
|
||||
'requested_task', 'rejected_task']
|
||||
'requested_task', 'rejected_task', 'position']
|
||||
|
||||
class JuniorProfileSerializer(serializers.ModelSerializer):
|
||||
"""junior serializer"""
|
||||
|
Reference in New Issue
Block a user