Skip to content

Commit

Permalink
Merge pull request #1685 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
rank count optimised
  • Loading branch information
adnankattekaden authored Dec 1, 2023
2 parents afbb7c4 + c17f11b commit d6d61e4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions api/dashboard/profile/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,14 @@ def get_rank(self, obj):
karma__gte=user_karma,
).order_by('-karma', '-updated_at', 'created_at')
else:
# ranks = (
# Wallet.objects.filter(karma__gte=user_karma).order_by('-karma', '-updated_at', 'created_at')
# )

ranks = (
Wallet.objects.filter(karma__gte=user_karma)
.exclude(
Q(user__user_role_link_user__role__title__in=[RoleType.ENABLER.value, RoleType.MENTOR.value])
).order_by('-karma')
)

count = 0
for _rank in ranks:
count += 1
for count, _rank in enumerate(ranks, start=0):
if obj == _rank.user:
return count

Expand Down

0 comments on commit d6d61e4

Please sign in to comment.