Skip to content

Commit e07435e

Browse files
Fixed Leaderboard
1 parent b0b99e5 commit e07435e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

main/views.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,19 +565,18 @@ def leaderboard_data(request):
565565
lb_data[user_profile.user.username] = user_profile.net_worth
566566
sorted_lb_data = sorted(
567567
lb_data.items(), key=operator.itemgetter(1), reverse=True)
568-
list_user_name = [x[0] for x in sorted_lb_data][:10]
569-
list_net_worth = [x[1] for x in sorted_lb_data][:10]
570-
count = len(list_net_worth)
571-
list_rank = [i for i in range(1, count+1)]
572-
573-
user_profile = UserProfile.objects.get(user=request.user)
574-
568+
list_user_name = [x[0] for x in sorted_lb_data]
575569
try:
576570
current_user_rank = list_user_name.index(user_profile.user.username)
577571
except:
578572
response_data = {'status': 'error',
579573
'message': 'Error in Retrieving Rank for Current User'}
580574
return JsonResponse(response_data)
575+
list_user_name = list_user_name[:10]
576+
list_net_worth = [x[1] for x in sorted_lb_data][:10]
577+
count = len(list_net_worth)
578+
list_rank = [i for i in range(1, count+1)]
579+
user_profile = UserProfile.objects.get(user=request.user)
581580

582581
try:
583582
user_profile.net_worth = 0

0 commit comments

Comments
 (0)