Skip to content

Commit

Permalink
add network to filters (#4351)
Browse files Browse the repository at this point in the history
* add network to filters

* Add mainnet filter
  • Loading branch information
octavioamu authored and danlipert committed May 2, 2019
1 parent 54ddd8d commit 9b6cdc5
Showing 1 changed file with 15 additions and 5 deletions.
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

0 comments on commit 9b6cdc5

Please sign in to comment.