Skip to content

Commit

Permalink
Use searches instead of topics for user keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
tfnribeiro committed Oct 7, 2024
1 parent c28733b commit 6cf10b0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions zeeguu/core/content_recommender/elastic_recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def _prepare_user_constraints(user):
# 1. Unwanted user topics
# ==============================
user_search_filters = SearchFilter.all_for_user(user)
unwanted_user_topics = []
unwanted_user_searches = []
for user_search_filter in user_search_filters:
unwanted_user_topics.append(user_search_filter.search.keywords)
print(f"keywords to exclude: {unwanted_user_topics}")
unwanted_user_searches.append(user_search_filter.search.keywords)
print(f"keywords to exclude: {unwanted_user_searches}")

# 2. Topics to exclude / filter out
# =================================
Expand Down Expand Up @@ -92,10 +92,10 @@ def _prepare_user_constraints(user):
# =========================================
user_subscriptions = SearchSubscription.all_for_user(user)

wanted_user_topics = []
wanted_user_searches = []
for sub in user_subscriptions:
wanted_user_topics.append(sub.search.keywords)
print(f"keywords to include: {wanted_user_topics}")
wanted_user_searches.append(sub.search.keywords)
print(f"keywords to include: {wanted_user_searches}")

return (
language,
Expand All @@ -105,8 +105,8 @@ def _prepare_user_constraints(user):
_list_to_string(topics_to_exclude),
_new_topics_to_string(new_topics_to_include),
_new_topics_to_string(new_topics_to_exclude),
_list_to_string(wanted_user_topics),
_list_to_string(unwanted_user_topics),
_list_to_string(wanted_user_searches),
_list_to_string(unwanted_user_searches),
)


Expand Down Expand Up @@ -147,8 +147,8 @@ def article_recommendations_for_user(
topics_to_exclude,
new_topics_to_include,
new_topics_to_exclude,
wanted_user_topics,
unwanted_user_topics,
wanted_user_searches,
unwanted_user_searches,
) = _prepare_user_constraints(user)
# build the query using elastic_query_builder
query_body = build_elastic_recommender_query(
Expand Down

0 comments on commit 6cf10b0

Please sign in to comment.