Apply the avoid filters to saved searches and topic browsing - #754
Open
mircealungu wants to merge 1 commit into
Open
mircealungu wants to merge 1 commit into
mircealungu wants to merge 1 commit into
Conversation
A saved-search subscription injected articles into the home feed through a query that applied neither the learner's "Topics to Avoid" keyword list nor their "Avoid disturbing news" setting, so an article matching a subscription appeared however it was classified and whatever it mentioned. Browsing a single topic had the same gap. Both filters are honored on the organic half of the feed, which is why this only showed up for subscribers. build_elastic_search_query now takes the two exclusions and applies the same must_not clauses build_elastic_recommender_query does. article_and_video_search_for_user had already computed both and was dropping them; it now passes them on, so the feed injection, the subscription preview and the subscription emails are all filtered. topic_filter_for_user applies them too. Where the two settings differ is what a learner can override. The keyword list yields to a term typed into the search box, which is an explicit instruction outranking a standing preference -- the one caller passing honor_avoid_keywords=False. The disturbing-content filter yields to nothing: it is a setting a teacher or a parent may have made, and one a learner can switch off by searching is not a setting. Also fixes a TypeError in topic_filter_for_user, which called Language.code as a method although it is a column -- the whole function raised before reaching any of its query. Closes #708 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
ArchLens - No architecturally relevant changes to the existing views |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #708.
Symptom
An article reached a learner's home feed through a saved-search subscription even when it matched their "Topics to Avoid" list, was classified as disturbing, or both. The organic half of the feed honors both settings; the search-injection half did not, so this only affected learners with a subscription.
Fix
build_elastic_search_querynow takes the avoid-keyword list and the disturbing flag and applies the samemust_notclausesbuild_elastic_recommender_queryalready does.article_and_video_search_for_userwas already computing both and then dropping them — it now passes them through, which covers the feed injection, the subscription preview and the subscription emails in one go.topic_filter_for_userapplies them too.The two settings differ in what a learner can override:
trumpand subscribes toirandid not ask for the intersection.Also fixes a
TypeErrorintopic_filter_for_user, which calledLanguage.codeas a method although it is a column — the function raised before reaching any of its query.Tests
zeeguu/core/test/test_avoid_filters_on_searches.py. The ones that matter go through the realarticle_and_video_search_for_userandtopic_filter_for_userwith a real user and read the query that actually reached Elasticsearch, since the gap was never in the builder but in the caller dropping what it had computed. All seven fail against the code before this change.Full suite green before and after (597 → 605 passed, 1 skipped).
🤖 Generated with Claude Code