Repository navigation
feat: 管理设置支持内部询问保留天数 - #122
Merged
Merged
Conversation
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.
将 #118 的内部询问保留天数接入管理设置,完成 MM-05,并按 MM-06 对齐两处既有测试的旧行为。
GET /admin/api/settings的goals.internal_question_expiry_days缺省返回 7。PATCH /admin/api/settings/goals接受该可选字段,严格整数 1—365;省略保留现值,非法类型或越界返回 400。可与default_reminder_minutes、overdue_reminders一起保存,沿用管理员会话、CSRF 和操作记录,所有设置与操作记录在同一事务中提交或回滚。读取默认值不回写数据库,部分保存保留所有已有键。沿用
runtime_settings.goals,无需迁移。README 目标一节已补充接口说明;页面由 UX 后续接入。既有断言调整仅限 MM-06 批准的内容:
tests/test_goals_api.py::test_admin_goal_crud_filters_settings_notifications_and_audit:GET 默认值、PATCH 旧字段后的两处精确返回值比较,各补入internal_question_expiry_days: 7。tests/test_question_goal_expiry.py::test_setting_write_persists_and_existing_admin_patch_preserves_internal_key:返回值公开已保存的保留天数,合法 PATCH 由预期 400 改为 200。保留其他断言及原有非法值检查,不跳过用例;新增测试覆盖越界和类型错误返回 400。验证:
tests/test_question_expiry_settings.py,34 项参数化实例,覆盖默认值、内部已有值、单独及混合 PATCH、遗漏保留、非法输入、操作记录及失败回滚、管理员会话与 CSRF/Origin/Host/JSON 防护。uv run pytest --show-capture=no,3747 passed(1143.66 秒)。uv run --locked --isolated --python 3.12 pytest --show-capture=no,3747 passed(1179.01 秒)。项目.venv保持 3.13。uv build:wheel 与 sdist 构建通过;本 worktree 的.pytest-tmp已清理。