From 63f9782cc7b4ad29e5eb029a8c8642608c4e53c9 Mon Sep 17 00:00:00 2001 From: Mircea Lungu Date: Sun, 25 Oct 2026 18:09:39 +0100 Subject: [PATCH] Drop what nobody reads of user_preference - UserWord.as_dictionary no longer sends user_preference: the web never read it (bookmarks carry no user_preference, so prioritizeBookmarksToStudy always returned early; web#1356 removes it). - The is_fit_for_study / not_fit_for_study endpoints go: their only caller was that function, past its early return, and both were broken (they set a non-column on Bookmark; not_fit_for_study passed a bookmark as a user word). - Looking a word up again no longer erodes "declared known" (-6 -> -4 ...): whether a word is known is the word-knowledge model's call. Before #903 it raised on the TEXT value, which is why prod has no -4 or -2 rows. First of the user_preference -> study_choice / unfit_reason PRs (docs/future-work/llm-tasks-roadmap.md, 0b). Co-Authored-By: Claude Opus 5.5 --- zeeguu/api/endpoints/bookmarks_and_words.py | 22 ------------------- zeeguu/core/model/bookmark.py | 10 --------- zeeguu/core/model/bookmark_user_preference.py | 8 +------ zeeguu/core/model/user_word.py | 1 - .../core/test/test_user_preference_as_text.py | 19 ---------------- 5 files changed, 1 insertion(+), 59 deletions(-) diff --git a/zeeguu/api/endpoints/bookmarks_and_words.py b/zeeguu/api/endpoints/bookmarks_and_words.py index 804e6aab2..185ec4ee4 100644 --- a/zeeguu/api/endpoints/bookmarks_and_words.py +++ b/zeeguu/api/endpoints/bookmarks_and_words.py @@ -341,28 +341,6 @@ def set_user_word_exercise_dislike(bookmark_id): return "OK" -@api.route("/is_fit_for_study/", methods=["POST"]) -@cross_domain -@requires_session -def set_is_fit_for_study(bookmark_id): - bookmark = get_bookmark_if_owned(bookmark_id) - bookmark.fit_for_study = True - db_session.commit() - return "OK" - - -@api.route("/not_fit_for_study/", methods=["POST"]) -@cross_domain -@requires_session -def set_not_fit_for_study(bookmark_id): - bookmark = get_bookmark_if_owned(bookmark_id) - bookmark.fit_for_study = False - - BasicSRSchedule.clear_user_word_schedule(db_session, bookmark) - db_session.commit() - return "OK" - - @api.route("/star_bookmark/", methods=["POST"]) @cross_domain @requires_session diff --git a/zeeguu/core/model/bookmark.py b/zeeguu/core/model/bookmark.py index 8c00f5ef1..5b9226804 100644 --- a/zeeguu/core/model/bookmark.py +++ b/zeeguu/core/model/bookmark.py @@ -629,22 +629,12 @@ def find_or_create( log(f"[BOOKMARK-TIMING] UserWord.find_or_create took {time.time() - uw_start:.3f}s") # Log every translation - from zeeguu.core.model.bookmark_user_preference import UserWordExPreference from zeeguu.core.model.user_word_interaction_history import UserWordInteractionHistory UserWordInteractionHistory.log( session, user_word, UserWordInteractionHistory.TRANSLATED ) - # Erode "declared known" confidence on re-translation - if UserWordExPreference.is_declared_known(user_word.user_preference): - # of(): the column is TEXT in prod, and "-6" + 2 raises - user_word.user_preference = UserWordExPreference.of(user_word.user_preference) + 2 - if user_word.user_preference >= UserWordExPreference.NO_PREFERENCE: - user_word.user_preference = UserWordExPreference.NO_PREFERENCE - user_word.update_fit_for_study(session) - session.add(user_word) - log(f"[BOOKMARK-TIMING] Getting Source") source = Source.find_by_id(source_id) diff --git a/zeeguu/core/model/bookmark_user_preference.py b/zeeguu/core/model/bookmark_user_preference.py index 74f001b0e..753a9f436 100644 --- a/zeeguu/core/model/bookmark_user_preference.py +++ b/zeeguu/core/model/bookmark_user_preference.py @@ -1,7 +1,7 @@ class UserWordExPreference(object): # Defines user preference to use word in exercises BAD_TRANSLATION = -100 # bad translation - permanent exclusion - DECLARED_KNOWN = -6 # freshly declared known, erodes with re-translations (-6 → -4 → -2 → 0) + DECLARED_KNOWN = -6 # declared known; whether it still is, is word knowledge's call DONT_USE_IN_EXERCISES = -1 # other reasons - permanent exclusion NO_PREFERENCE = 0 USE_IN_EXERCISES = 1 # user explicitly opted in (overrides quality checks) @@ -16,9 +16,3 @@ def of(cls, preference): return int(preference or cls.NO_PREFERENCE) except (ValueError, TypeError): return cls.NO_PREFERENCE - - @classmethod - def is_declared_known(cls, preference): - """Declared known uses even negative values: -6, -4, -2""" - pref = cls.of(preference) - return pref <= -2 and pref >= -6 and pref % 2 == 0 diff --git a/zeeguu/core/model/user_word.py b/zeeguu/core/model/user_word.py index f2bc3a59b..758c97bbf 100644 --- a/zeeguu/core/model/user_word.py +++ b/zeeguu/core/model/user_word.py @@ -267,7 +267,6 @@ def as_dictionary(self, schedule=None, pre_tokenized_context=None, with_context_ is_about_to_be_learned=is_about_to_be_learned, fast_track=fast_track, can_update_schedule=can_update_schedule, - user_preference=self.user_preference, consecutive_correct_answers=consecutive_correct_answers, context_in_content=self.preferred_bookmark.text.in_content, left_ellipsis=self.preferred_bookmark.context.left_ellipsis, diff --git a/zeeguu/core/test/test_user_preference_as_text.py b/zeeguu/core/test/test_user_preference_as_text.py index e654b557d..df3a3be72 100644 --- a/zeeguu/core/test/test_user_preference_as_text.py +++ b/zeeguu/core/test/test_user_preference_as_text.py @@ -8,10 +8,6 @@ from zeeguu.core.bookmark_quality.fit_for_study import fit_for_study from zeeguu.core.llm_services.translation_validator import ValidationResult from zeeguu.core.llm_services.validation_service import UserWordValidationService -from zeeguu.core.model.bookmark import Bookmark -from zeeguu.core.model.bookmark_user_preference import UserWordExPreference -from zeeguu.core.model.context_identifier import ContextIdentifier -from zeeguu.core.model.context_type import ContextType from zeeguu.core.model.meaning import Meaning from zeeguu.core.model.user_word import UserWord from zeeguu.core.test.model_test_mixin import ModelTestMixIn @@ -29,21 +25,6 @@ def setUp(self): self.user_word = self.bookmark.user_word self.meaning = self.user_word.meaning - def test_looking_up_a_word_declared_known_again_erodes_the_text_value(self): - self.user_word.user_preference = "-6" # as prod returns it - - Bookmark.find_or_create( - session, self.user, - self.meaning.origin.content, self.meaning.origin.language.code, - self.meaning.translation.content, self.meaning.translation.language.code, - f"Det er {self.meaning.origin.content} her.", None, None, - sentence_i=0, token_i=2, total_tokens=1, c_sentence_i=0, c_token_i=0, - context_identifier=ContextIdentifier(context_type=ContextType.USER_EDITED_TEXT), - translation_source="reading", - ) - - self.assertEqual(self.user_word.user_preference, UserWordExPreference.DECLARED_KNOWN + 2) - def test_an_audio_lesson_adds_a_word_whose_preference_is_a_text_zero(self): from zeeguu.core.bookmark_operations.add_word_to_study import add_word_to_study