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

Fix matching logic #4050

Merged
merged 5 commits into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion app/assets/v2/js/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ var get_search_URI = function(offset, order) {
}

if (keywords) {
uri += '&raw_data=' + keywords;
uri += '&keywords=' + keywords;
}

if (localStorage['org']) {
Expand Down
6 changes: 5 additions & 1 deletion app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ $(document).ready(function() {
.removeAttr('disabled');

$.each($(form).serializeArray(), function() {
data[this.name] = this.value;
if (data[this.name]) {
data[this.name] += ',' + this.value;
} else {
data[this.name] = this.value;
}
});

if (data.repo_type == 'private' && data.project_type != 'traditional' && data.permission_type != 'approval') {
Expand Down
10 changes: 8 additions & 2 deletions app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ def get_queryset(self):
if self.request.query_params.get('misc') == 'hiring':
queryset = queryset.exclude(attached_job_description__isnull=True).exclude(attached_job_description='')

if 'keyword' in param_keys:
queryset = queryset.keyword(self.request.query_params.get('keyword'))
# Keyword search to search all comma separated keywords
queryset_original = queryset
if 'keywords' in param_keys:
for index, keyword in enumerate(self.request.query_params.get('keywords').split(',')):
if index == 0:
queryset = queryset_original.keyword(keyword)
else:
queryset |= queryset_original.keyword(keyword)

if 'is_featured' in param_keys:
queryset = queryset.filter(
Expand Down
22 changes: 3 additions & 19 deletions app/marketing/management/commands/new_bounties_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,18 @@
from marketing.models import EmailSubscriber


def does_bounty_match_keyword(bounty, keyword):
if keyword.lower() in [keyword.lower() for keyword in bounty.keywords_list]:
return True

if keyword.lower() in bounty.title_or_desc.lower():
return True

if keyword.lower() in bounty.issue_description.lower():
return True

return False


def get_bounties_for_keywords(keywords, hours_back):
new_bounties_pks = []
all_bounties_pks = []
for keyword in keywords:
relevant_bounties = Bounty.objects.current().filter(
network='mainnet',
metadata__issueKeywords__icontains=keyword,
idx_status__in=['open'],
)
).keyword(keyword)
for bounty in relevant_bounties.filter(web3_created__gt=(timezone.now() - timezone.timedelta(hours=hours_back))):
if does_bounty_match_keyword(bounty, keyword):
new_bounties_pks.append(bounty.pk)
new_bounties_pks.append(bounty.pk)
for bounty in relevant_bounties:
if does_bounty_match_keyword(bounty, keyword):
all_bounties_pks.append(bounty.pk)
all_bounties_pks.append(bounty.pk)
new_bounties = Bounty.objects.filter(pk__in=new_bounties_pks).order_by('-_val_usd_db')
all_bounties = Bounty.objects.filter(pk__in=all_bounties_pks).exclude(pk__in=new_bounties_pks).order_by('-_val_usd_db')

Expand Down