/
pa1ch
/
FitAssistant
Обзор
Документация
Войти
/
pa1ch
/
FitAssistant
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/models/exercise_preference.py
33 строки
1 KB
Pavel Chugaev
Заменить ручной дизлайк упражнений на неявный скор релевантности
14 июл 2026, 12:24
14 июл 2026, 12:24
cccb100
Код
Авторство
О чём код?
import enum from sqlalchemy import ForeignKey, String, UniqueConstraint from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base class ExercisePreferenceValue(enum.StrEnum): """How a user marked an exercise. Stored as the string value. One row per (user, exercise); absence of a row means "no opinion". A single table with a status column (rather than separate per-mark tables) keeps the toggle logic in one place — a user can only hold one state for a given exercise at once. EXCLUDED means "never recommend this" (e.g. injury) — a hard filter. There's no manual "dislike": that soft signal is now inferred automatically (see app.services.exercise.get_exercise_scores) from usage and AI-generation replacement history instead of asking the user to curate it. """ FAVORITE = "favorite" EXCLUDED = "excluded" class UserExercisePreference(Base): __tablename__ = "user_exercise_preferences" __table_args__ = (UniqueConstraint("user_id", "exercise_id"),) user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True) exercise_id: Mapped[int] = mapped_column( ForeignKey("exercises.id", ondelete="CASCADE"), index=True ) preference: Mapped[str] = mapped_column(String(16))