Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add network to filters #4351

Merged
merged 2 commits into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,10 @@ def users_fetch(request):
rating = int(request.GET.get('rating', '0'))

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

user_list = Profile.objects.prefetch_related('fulfilled', 'leaderboard_ranks', 'feedbacks_got').order_by(order_by)

Expand All @@ -774,10 +778,11 @@ def users_fetch(request):
user_list = user_list.filter(keywords__icontains=skills)

if len(bounties_completed) == 2:
user_list = user_list.annotate(count=Count('fulfilled')) \
.filter(
user_list = user_list.annotate(
count=Count('fulfilled', filter=Q(fulfilled__bounty__network=network))
).filter(
count__gte=bounties_completed[0],
count__lte=bounties_completed[1]
count__lte=bounties_completed[1],
)

if len(leaderboard_rank) == 2:
Expand All @@ -790,7 +795,7 @@ def users_fetch(request):

if rating != 0:
user_list = user_list.annotate(
average_rating=Avg('feedbacks_got__rating')
average_rating=Avg('feedbacks_got__rating', filter=Q(feedbacks_got__bounty__network=network))
).filter(
average_rating__gte=rating
)
Expand Down Expand Up @@ -844,9 +849,14 @@ def get_user_bounties(request):
profile = Profile.objects.get(id=int(user_id))
else:
profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None
if not settings.DEBUG:
network = 'mainnet'
else:
network = 'rinkeby'

params = dict()
results = []
open_bounties = Bounty.objects.current().filter(bounty_owner_github_username__iexact=profile.handle) \
open_bounties = Bounty.objects.current().filter(bounty_owner_github_username__iexact=profile.handle, network=network) \
.exclude(idx_status='cancelled').exclude(idx_status='done')
for bounty in open_bounties:
bounty_json = {}
Expand Down