Skip to content

Commit

Permalink
Fix usdc search filter (#6188)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Sep 30, 2023
1 parent 857f43b commit a174986
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion discovery-provider/src/api/v1/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ def add_auth_headers_to_parser(parser):
full_search_parser.add_argument(
"includePurchaseable",
required=False,
type=bool,
type=str,
description="Whether or not to include purchaseable content",
)

Expand Down
7 changes: 5 additions & 2 deletions discovery-provider/src/api/v1/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
full_search_parser,
get_current_user_id,
make_full_response,
parse_bool_param,
success_response,
)
from src.api.v1.models.search import search_model
Expand Down Expand Up @@ -43,6 +44,7 @@ def get(self):
offset = format_offset(args)
limit = format_limit(args)
current_user_id = get_current_user_id(args)
include_purchaseable = parse_bool_param(args.get("includePurchaseable"))

search_args = {
"is_auto_complete": False,
Expand All @@ -53,7 +55,7 @@ def get(self):
"limit": limit,
"offset": offset,
"only_downloadable": False,
"include_purchaseable": args.get("includePurchaseable", False),
"include_purchaseable": include_purchaseable,
}
resp = search(search_args)
return success_response(resp)
Expand Down Expand Up @@ -84,6 +86,7 @@ def get(self):
offset = format_offset(args)
limit = format_limit(args)
current_user_id = get_current_user_id(args)
include_purchaseable = parse_bool_param(args.get("includePurchaseable"))

search_args = {
"is_auto_complete": True,
Expand All @@ -94,7 +97,7 @@ def get(self):
"limit": limit,
"offset": offset,
"only_downloadable": False,
"include_purchaseable": args.get("includePurchaseable", False),
"include_purchaseable": include_purchaseable,
}
resp = search(search_args)
return success_response(resp)
8 changes: 6 additions & 2 deletions discovery-provider/src/api/v1/utils/extend_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ def extend_usdc_purchase_seller(action: NotificationAction):
"buyer_user_id": encode_int_id(data["buyer_user_id"]),
"seller_user_id": encode_int_id(data["seller_user_id"]),
"amount": str(data["amount"]),
"extra_amount": str(data["extra_amount"]),
"extra_amount": str(data["extra_amount"])
if "extra_amount" in data
else "0",
"content_id": encode_int_id(data["content_id"]),
},
}
Expand All @@ -484,7 +486,9 @@ def extend_usdc_purchase_buyer(action: NotificationAction):
"buyer_user_id": encode_int_id(data["buyer_user_id"]),
"seller_user_id": encode_int_id(data["seller_user_id"]),
"amount": str(data["amount"]),
"extra_amount": str(data["extra_amount"]),
"extra_amount": str(data["extra_amount"])
if "extra_amount" in data
else "0",
"content_id": encode_int_id(data["content_id"]),
},
}
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/src/queries/search_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def tag_match(fieldname, sort_by):
"query": {
"bool": {
"must": [{"match": {fieldname: {"query": q}}}],
"must_not": [],
"must_not": [{"term": {"purchaseable": {"value": True}}}],
"should": [],
}
},
Expand Down

0 comments on commit a174986

Please sign in to comment.