Skip to content

Commit

Permalink
Address comments by dan
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed May 24, 2019
1 parent 9088073 commit e21cef6
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,30 +766,37 @@ def users_fetch(request):

user_id = request.GET.get('user', None)
if user_id:
profile = User.objects.get(id=int(user_id))
current_user = User.objects.get(id=int(user_id))
else:
profile = request.user if hasattr(request, 'user') and request.user.is_authenticated else None
current_user = request.user if hasattr(request, 'user') and request.user.is_authenticated else None

context = {}
if not settings.DEBUG:
network = 'mainnet'
else:
network = 'rinkeby'


user_list = Profile.objects.prefetch_related(
'fulfilled', 'leaderboard_ranks', 'feedbacks_got'
).annotate(
previous_worked_count=Count('fulfilled', filter=Q(
fulfilled__bounty__network=network,
fulfilled__accepted=True,
fulfilled__bounty__bounty_owner_github_username__iexact=profile.username
))
).order_by(
'-previous_worked_count',
order_by,
'-actions_count'
)
if current_user:
user_list = Profile.objects.prefetch_related(
'fulfilled', 'leaderboard_ranks', 'feedbacks_got'
).annotate(
previous_worked_count=Count('fulfilled', filter=Q(
fulfilled__bounty__network=network,
fulfilled__accepted=True,
fulfilled__bounty__bounty_owner_github_username__iexact=current_user.username
))
).order_by(
'-previous_worked_count',
order_by,
'-actions_count'
)
else:
user_list = Profile.objects.prefetch_related(
'fulfilled', 'leaderboard_ranks', 'feedbacks_got'
).order_by(
order_by,
'-actions_count'
)

if q:
user_list = user_list.filter(Q(handle__icontains=q) | Q(keywords__icontains=q))
Expand Down

0 comments on commit e21cef6

Please sign in to comment.