added notification for existing junior add, modified leaderboard method at every places

This commit is contained in:
abutalib-kiwi
2023-08-28 19:39:39 +05:30
parent df3cab99a5
commit 219bae792e
7 changed files with 56 additions and 36 deletions

View File

@ -70,10 +70,12 @@ def get_junior_leaderboard_rank(junior_obj):
:param junior_obj:
:return: junior's position/rank
"""
queryset = JuniorPoints.objects.select_related('junior', 'junior__auth').annotate(rank=Window(
expression=Rank(),
order_by=[F('total_points').desc(), 'junior__created_at']
)).order_by('-total_points', 'junior__created_at')
queryset = JuniorPoints.objects.filter(
junior__is_verified=True
).select_related('junior', 'junior__auth').annotate(rank=Window(
expression=Rank(),
order_by=[F('total_points').desc(), 'junior__created_at']
)).order_by('-total_points', 'junior__created_at')
junior = next((query for query in queryset if query.junior == junior_obj), None)